MapWithDefaultCompanion

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

Extends a MapCompanion by adding a default value as a fallback.

Constructors

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

Properties

Link copied to clipboard
val default: E
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
fun getOrDefault(key: K?): E

Returns the element matching the key, or the default value as a fallback.

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

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