Package 

Class MapCompanion


  • 
    public class MapCompanion<K extends Object, E extends Object>
    
                        

    Encapsulates a Map into a more limited query API.

    This is most useful as an Enum companion, to provide parsing of raw values.

    enum class Layout(val value: String) {
        PAGINATED("paginated"),
        REFLOWABLE("reflowable");
    
        companion object : KeyMapper<String, Layout>(values(), Layout::value)
    }
    
    val layout: Layout? = Layout("reflowable")
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private final Set<K> keys
    • Method Summary

      Modifier and Type Method Description
      final Set<K> getKeys()
      E get(K key) Returns the element matching the key, or null if not found.
      E invoke(K key) Alias to get, to be used like keyMapper("a_key").
      E from(K key)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MapCompanion

        MapCompanion(Array<E> elements, Function1<E, K> keySelector)
      • MapCompanion

        MapCompanion(Map<K, E> map)
    • Method Detail

      • get

         E get(K key)

        Returns the element matching the key, or null if not found.

        To be overridden in subclasses if custom retrieval is needed – for example, testing lowercase keys.

      • invoke

         E invoke(K key)

        Alias to get, to be used like keyMapper("a_key").