MapCompanion

open class MapCompanion<K, E>(map: Map<K, E>)

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")

Inheritors

Constructors

Link copied to clipboard
constructor(map: Map<K, E>)
constructor(elements: Array<E>, keySelector: (E) -> K)

Properties

Link copied to clipboard
val keys: Set<K>

Returns the available keys.

Functions

Link copied to clipboard
open fun get(key: K?): E?

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

Link copied to clipboard
open operator fun invoke(key: K?): E?

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