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

Just

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

Constructors

<init>

Just(value: A)

Functions

equals

fun equals(other: Any?): Boolean

filter

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

flatMap

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

get

fun get(): A

getOrElse

fun getOrElse(ignored: A?): A

hashCode

fun hashCode(): Int

ifJust

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

ifNothing

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

isJust

fun isJust(): Boolean

map

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

orElse

fun orElse(ignored: Maybe<A>): Maybe<A>
fun orElse(ignored: 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!).