Package 

Class MapCompanion

  • All Implemented Interfaces:

    
    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")
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

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

      Enum Constants 
      Enum Constant Description
    • 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 overriden 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").

      • from

        @Deprecated(message = "Use `Enum("value")` instead", replaceWith = @ReplaceWith(imports = {}, expression = "get(key)")) E from(K key)