NotEmptyMap

@Serializable(with = NotEmptyMapSerializer::class)
class NotEmptyMap<K, out V> : Map<K, V>

Representation of maps that contain at least one entry.

Parameters

K

The type of map keys.

V

The type of map values.

Functions

Link copied to clipboard
open override fun containsKey(key: K): Boolean
Link copied to clipboard
open override fun containsValue(value: V): Boolean
Link copied to clipboard
open operator override fun get(key: K): V?
Link copied to clipboard
open override fun isEmpty(): Boolean
Link copied to clipboard
open override fun toString(): String

Properties

Link copied to clipboard
open override val entries: Set<Map.Entry<K, V>>
Link copied to clipboard
open override val keys: Set<K>
Link copied to clipboard
open override val size: Int
Link copied to clipboard
open override val values: Collection<V>

Extensions

Link copied to clipboard

Returns a NotEmptyMap containing all the entries of this map, or an IllegalArgumentException if this map is empty.

fun <K, V> Map<K, V>.toNotEmptyMap(): NotEmptyMap<K, V>

Returns a NotEmptyMap containing all the entries of this map, or throws a NotEmptyMap.ConstructionError if this map is empty.

Link copied to clipboard
inline fun <K, V> Map<K, V>.toNotEmptyMapOrElse(defaultValue: (Map<K, V>) -> NotEmptyMap<K, V>): NotEmptyMap<K, V>

Returns a NotEmptyMap containing all the entries of this map, or returns the result of calling the defaultValue function if this map is empty.

Link copied to clipboard

Returns a NotEmptyMap containing all the entries of this map, or returns null if this map is empty.

Link copied to clipboard

Returns a NotEmptyMap containing all the entries of this map, or throws an IllegalArgumentException if this map is empty.