Package com.github.tonivade.purefun.type
Interface Option<T>
- Type Parameters:
T- the wrapped value
- All Superinterfaces:
Applicable<Option<?>,,T> Bindable<Option<?>,,T> Kind<Option<?>,,T> Mappable<Option<?>,,T> OptionOf<T>
- All Known Implementing Classes:
Option.None,Option.Some
public sealed interface Option<T>
extends OptionOf<T>, Bindable<Option<?>,T>, Applicable<Option<?>,T>
permits Option.Some<T>, Option.None<T>
This type represents the presence or absence of a value, similar to Optional
There are two possible values:
Option.none(): that represent the absence of a valueOption.some(value): that represent the presence of a value
Note: it's serializable
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classstatic final recordNested classes/interfaces inherited from interface com.github.tonivade.purefun.core.Applicable
Applicable.Map2<F extends Applicable<F,?>, A, B>, Applicable.Map3<F extends Applicable<F, ?>, A, B, C>, Applicable.Map4<F extends Applicable<F, ?>, A, B, C, D>, Applicable.Map5<F extends Applicable<F, ?>, A, B, C, D, E> -
Method Summary
Modifier and TypeMethodDescriptiondefault <R> Option<R> default <R> Option<R> default <U> Ustatic <T> Option<T> default Tdefault Tdefault Tdefault TgetOrElseThrow(Producer<? extends X> producer) booleanisEmpty()booleandefault <R> Option<R> static <A,B, Z> Option <Z> static <T> Option<T> none()static <T> Option<T> static <T> Option<T> of(T value) sequence()static <T> Option<T> some(T value) stream()toEither()toTry()Methods inherited from interface com.github.tonivade.purefun.core.Applicable
zip, zipLeft, zipRight, zipWith
-
Method Details
-
some
-
none
-
of
-
of
-
from
-
map2
-
isPresent
boolean isPresent() -
isEmpty
boolean isEmpty() -
map
-
ap
- Specified by:
apin interfaceApplicable<Option<?>,T>
-
flatMap
-
ifPresent
-
ifEmpty
-
filter
-
filterNot
-
or
-
orElse
-
getOrElse
-
getOrElseNull
-
getOrElse
-
getOrElseThrow
-
getOrElseThrow
- Throws:
X
-
fold
-
stream
-
sequence
-
toOptional
-
toEither
-
toTry
-