Package org.midheaven.lang
Interface Maybe<T>
public sealed interface Maybe<T>
Defines the contract for Maybe.
-
Method Summary
Modifier and TypeMethodDescription<R> Maybe<R> <R,S> Maybe <R> flatZip(Maybe<S> other, BiFunction<T, S, Maybe<R>> calculation) static <X> Maybe<X> Creates an instance from the provided source.get()voidPerforms ifPresent.voidifPresentOrElse(Consumer<T> consumer, Runnable action) Performs ifPresentOrElse.booleanisAbsent()Checks whether is Absent.booleanChecks whether is Present.<R> Maybe<R> static <X> Maybe<X> none()Performs none.static <X> Maybe<X> of(X value) Creates an instance from the provided value.<R> Maybe<R> Transforms the value T to type R.orElseThrow(Supplier<E> supplier) orNull()static <X> Maybe<X> some(X value) Performs some.Performs ifPresent.<R,S> Maybe <R> zip(Maybe<S> other, BiFunction<T, S, R> calculation)
-
Method Details
-
none
Performs none.- Returns:
- the result of none
-
of
Creates an instance from the provided value.- Parameters:
value- the value value- Returns:
- the result of of
-
some
Performs some.- Parameters:
value- the value value- Returns:
- the result of some
-
from
Creates an instance from the provided source.- Parameters:
optional- the optional value- Returns:
- the result of from
-
enumerable
Enumerable<T> enumerable() -
get
T get() -
isPresent
boolean isPresent()Checks whether is Present.- Returns:
- the result of isPresent
-
isAbsent
boolean isAbsent()Checks whether is Absent.- Returns:
- the result of isAbsent
-
ofType
Transforms the value T to type R. If the value is not of type T returnnone()- Type Parameters:
R-- Parameters:
type-- Returns:
-
filter
-
map
-
flatMap
-
orNull
T orNull() -
orElseThrow
T orElseThrow() -
orElseThrow
- Throws:
E
-
orElse
-
orElseGet
-
or
-
orGet
-
zip
-
flatZip
-
merge
-
flatMerge
-
toOptional
Performs ifPresent. -
ifPresent
Performs ifPresent.- Parameters:
consumer- the consumer value
-
ifPresentOrElse
Performs ifPresentOrElse.- Parameters:
consumer- the consumer valueaction- the action value
-