sdk-common / com.tomtom.online.sdk.common.functional / Maybe / Nothing

Nothing

class Nothing<A : Any!> : Maybe<A>

Constructors

<init>

Nothing()

Functions

filter

fun filter(predicate: Predicate<in A>): Maybe<A>

flatMap

fun <B : Any!> flatMap(ignored: (in A) -> out Maybe<out B>!): Maybe<B>

get

fun get(): A

getOrElse

fun getOrElse(defaultValue: A?): A

ifJust

fun ifJust(action: Consumer1<A>): Maybe<A>

ifNothing

fun ifNothing(action: Consumer0): Maybe<A>

isJust

fun isJust(): Boolean

map

fun <B : Any!> map(ignored: (in A) -> out B): Maybe<B>

orElse

fun orElse(defaultMaybe: Maybe<A>): Maybe<A>
fun orElse(supplier: Supplier<Maybe<A>!>): Maybe<A>

Inherited Functions

getOrNull

open fun getOrNull(): A?

Returns value stored in Just or null value in case of Nothing.

getOrThrow

open fun <E : Exception!> getOrThrow(exception: Exception): A

Returns Just value or in case of Nothing throws an exception specified as the argument.

isNothing

open fun isNothing(): Boolean

Checks if the Maybe is a Nothing.

iterator

open fun iterator(): MutableIterator<A>

just

open static fun <B : Any!> just(value: B): Maybe<B>

Creates a Just from the given value. Please be aware that if the value is null then a null will get stored. If you don't want to store or process a potential null value please use Maybe#ofNullable(Object) instead.

nothing

open static fun <B : Any!> nothing(): Maybe<B>

Creates a Nothing.

ofNullable

open static fun <B : Any!> ofNullable(value: B?): Maybe<B>

Creates a Maybe from a given value. If the value is null a Nothing will be created.

unit

open static fun <R : Any!> unit(): (R) -> Maybe<R>!

Returns a function that takes a value and returns a monad of that value. The returned function will always return a Just regardless of the passed value (even null!).