Package-level declarations

Contains types such as NotEmptyList for manipulating collections.

Types

Link copied to clipboard
@SinceKotoolsTypes(version = "4.1")
interface NotEmptyCollection<out E>

Representation of collections containing at least one element of type E.

Link copied to clipboard
@Serializable(with = NotEmptyListSerializer::class)
@SinceKotoolsTypes(version = "4.0")
value class NotEmptyList<out E> : NotEmptyCollection<E>

Represents a list with at least one element of type E.

Link copied to clipboard
@Serializable(with = NotEmptyMapSerializer::class)
@SinceKotoolsTypes(version = "4.0")
value class NotEmptyMap<K, out V>

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

Link copied to clipboard
@Serializable(with = NotEmptySetSerializer::class)
@SinceKotoolsTypes(version = "4.0")
value class NotEmptySet<out E> : NotEmptyCollection<E>

Represents a set with at least one element of type E.

Functions

Link copied to clipboard
@SinceKotoolsTypes(version = "4.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
@SinceKotoolsTypes(version = "4.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
@SinceKotoolsTypes(version = "4.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
@SinceKotoolsTypes(version = "4.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
@ExperimentalSinceKotoolsTypes(version = "4.3.1")
fun <E> Collection<E>.toNotEmptyListOrNull(): NotEmptyList<E>?

Returns a NotEmptyList containing all the elements of this collection, or returns null if this collection is empty.

Link copied to clipboard
@ExperimentalSinceKotoolsTypes(version = "4.3.1")
fun <E> Collection<E>.toNotEmptyListOrThrow(): NotEmptyList<E>

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

Link copied to clipboard
@SinceKotoolsTypes(version = "4.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
@ExperimentalSinceKotoolsTypes(version = "4.3.1")
fun <K, V> Map<K, V>.toNotEmptyMapOrNull(): NotEmptyMap<K, V>?

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

Link copied to clipboard
@ExperimentalSinceKotoolsTypes(version = "4.3.1")
fun <K, V> Map<K, V>.toNotEmptyMapOrThrow(): NotEmptyMap<K, V>

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

Link copied to clipboard
@SinceKotoolsTypes(version = "4.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.

Link copied to clipboard
@ExperimentalSinceKotoolsTypes(version = "4.3.1")
fun <E> Collection<E>.toNotEmptySetOrNull(): NotEmptySet<E>?

Returns a NotEmptySet containing all the elements of this collection, or returns null if this collection is empty.

Link copied to clipboard
@ExperimentalSinceKotoolsTypes(version = "4.3.1")
fun <E> Collection<E>.toNotEmptySetOrThrow(): NotEmptySet<E>

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

Properties

Link copied to clipboard
@SinceKotoolsTypes(version = "4.1")
val NotEmptyCollection<*>?.sizeOrZero: PositiveInt

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