Package-level declarations

Contains types such as NotEmptyList for manipulating collections.

Types

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_1_0)
interface NotEmptyCollection<out E>

Represents a collection that has at least one element of type E.

Link copied to clipboard
@Serializable(with = NotEmptyListSerializer::class)
@Since(version = KotoolsTypesVersion.V4_0_0)
value class NotEmptyList<out E> : NotEmptyCollection<E>

Represents a list that has at least one element of type E.

Link copied to clipboard
@Serializable(with = NotEmptyMapSerializer::class)
@Since(version = KotoolsTypesVersion.V4_0_0)
value class NotEmptyMap<K, out V>

Represents a map that has at least one entry, with a key of type K and a value of type V.

Link copied to clipboard
@Serializable(with = NotEmptySetSerializer::class)
@Since(version = KotoolsTypesVersion.V4_0_0)
value class NotEmptySet<out E> : NotEmptyCollection<E>

Represents a set that has at least one element of type E.

Functions

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_0_0)
fun <E> notEmptyListOf(head: E, vararg tail: E): NotEmptyList<E>

Creates a NotEmptyList starting with a head and containing all the elements of the optional tail.

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_0_0)
fun <K, V> notEmptyMapOf(head: Pair<K, V>, vararg tail: Pair<K, V>): NotEmptyMap<K, V>

Creates a NotEmptyMap starting with a head and containing all the entries of the optional tail.

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_0_0)
fun <E> notEmptySetOf(head: E, vararg tail: E): NotEmptySet<E>

Creates a NotEmptySet starting with a head and containing all the elements of the optional tail.

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_0_0)
fun <E> Collection<E>.toNotEmptyList(): Result<NotEmptyList<E>>

Returns an encapsulated NotEmptyList containing all the elements of this collection, or returns an encapsulated IllegalArgumentException if this collection is empty.

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_0_0)
fun <K, V> Map<K, V>.toNotEmptyMap(): Result<NotEmptyMap<K, V>>

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

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_0_0)
fun <E> Collection<E>.toNotEmptySet(): Result<NotEmptySet<E>>

Returns an encapsulated NotEmptySet containing all the elements of this collection, or returns an encapsulated IllegalArgumentException if this collection is empty.

Properties

Link copied to clipboard
@Since(version = KotoolsTypesVersion.V4_1_0)
val NotEmptyCollection<*>?.sizeOrZero: PositiveInt

Returns the size of this collection, or returns ZeroInt if this collection is null.