Package-level declarations

Types

Link copied to clipboard

Represents a value that encapsulates all three possible states of a value in the Discord API. Specifically:

Link copied to clipboard
Link copied to clipboard

Represents a value that encapsulate the optional and value state of an Int in the Discord API. Specifically:

Link copied to clipboard

Represents a value that encapsulate the optional and value state of a Long in the Discord API. Specifically:

Link copied to clipboard

Properties

Link copied to clipboard

returns null if this is null, calls OptionalBoolean.asNullable otherwise.

returns null if this is null, calls OptionalInt.asNullable otherwise.

returns null if this is null, calls OptionalLong.asNullable otherwise.

Link copied to clipboard

returns null if this is null or OptionalBoolean.Missing, calls OptionalBoolean.Value.value otherwise.

returns null if this is null or OptionalInt.Missing, calls OptionalInt.Value.value otherwise.

returns null if this is null, calls OptionalLong.asNullable otherwise.

returns null if this is null or OptionalSnowflake.Missing, calls OptionalSnowflake.Value.value otherwise.

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
inline fun <E> Optional<List<E>>.filterList(mapper: (E) -> Boolean): Optional<List<E>>
Link copied to clipboard
inline fun <E> Optional<List<E>>.first(predicate: (E) -> Boolean): E
Link copied to clipboard
inline fun <E> Optional<List<E>>.firstOrNull(predicate: (E) -> Boolean): E?
Link copied to clipboard
inline fun <E : Any, T : Any> Optional<E>.flatMap(mapper: (E) -> Optional<T>): Optional<T>

Applies the mapper to the optional if it is a Value, returns the same optional otherwise.

Link copied to clipboard

returns the value of the optional or throws a IllegalStateException if the optional doesn't contain a value or is null.

Link copied to clipboard
inline fun OptionalInt.map(mapper: (Int) -> Int): OptionalInt
inline fun <T : Any> OptionalSnowflake.map(mapper: (Snowflake) -> T): Optional<T>
@JvmName(name = "mapNullableOptional")
inline fun <E : Any, T : Any> Optional<E?>.map(mapper: (E) -> T): Optional<T?>
inline fun <E : Any, T : Any> Optional<E>.map(mapper: (E) -> T): Optional<T>
Link copied to clipboard
@JvmName(name = "mapCopyOfMap")
fun <K, V> Optional<MutableMap<K, V>>.mapCopy(): Optional<Map<K, V>>
Link copied to clipboard
@JvmName(name = "mapNullableList")
inline fun <E, T> Optional<List<E>?>.mapList(mapper: (E) -> T): Optional<List<T>?>
inline fun <E, T> Optional<List<E>>.mapList(mapper: (E) -> T): Optional<List<T>>
Link copied to clipboard
inline fun <E : Any, T> Optional<E?>.mapNotNull(mapper: (E) -> T): Optional<T?>
Link copied to clipboard
inline fun <E, T> Optional<E>.mapNullable(mapper: (E) -> T): Optional<T?>
Link copied to clipboard
@JvmName(name = "mapNullableSnowflake")
inline fun <E : Any> Optional<E?>.mapSnowflake(mapper: (E) -> Snowflake): OptionalSnowflake
inline fun <E : Any> Optional<E>.mapSnowflake(mapper: (E) -> Snowflake): OptionalSnowflake
Link copied to clipboard
inline fun <K, V, R> Optional<Map<K, V>>.mapValues(mapper: (Map.Entry<K, V>) -> R): Optional<Map<K, R>>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

returns default if this is null, calls OptionalBoolean.asNullable otherwise.

fun OptionalInt?.orElse(default: Int): Int

returns default if this is null, calls OptionalInt.asNullable otherwise.

fun OptionalLong?.orElse(default: Long): Long

returns default if this is null, calls OptionalLong.asNullable otherwise.

Link copied to clipboard
fun <E> Optional<List<E>>.orEmpty(): List<E>
fun <E> Optional<Set<E>>.orEmpty(): Set<E>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
inline fun <T, R : Any> Optional<T>.unwrap(mapper: (T) -> R): R?