public abstract class IOption<T>
extends java.lang.Object
implements java.lang.Iterable<T>
| Modifier and Type | Class and Description |
|---|---|
static class |
IOption.None<T> |
static class |
IOption.Some<T> |
| Constructor and Description |
|---|
IOption() |
| Modifier and Type | Method and Description |
|---|---|
abstract IOption<T> |
filter(IFunction<? super T,java.lang.Boolean> fn) |
abstract <R> IOption<R> |
flatMap(IFunction<? super T,IOption<R>> fn) |
abstract void |
forEach(IConsumer<? super T> fn) |
abstract T |
get()
Throws an exception if this option is
IOption.None. |
abstract T |
getOrElse(ISupplier<? extends T> orElseFn) |
abstract T |
getOrElse(T orElse) |
abstract IOption<T> |
ifDefined(IConsumer<? super T> fn) |
abstract IOption<T> |
ifEmpty(ICommand fn) |
boolean |
isDefined() |
abstract boolean |
isEmpty() |
java.util.Iterator<T> |
iterator() |
abstract <R> IOption<R> |
map(IFunction<? super T,R> fn) |
static <R> IOption<R> |
none() |
static <R> IOption<R> |
ofNullable(R value) |
abstract IOption<T> |
orElse(ISupplier<? extends T> orElseFn) |
abstract IOption<T> |
orElse(T orElse) |
abstract IOption<T> |
orElseFlat(IOption<T> orElse) |
abstract IOption<T> |
orElseFlat(ISupplier<IOption<T>> orElseFn) |
abstract T |
orNull()
Returns the current option's value or
null if this option is IOption.None. |
static <R> IOption<R> |
some(R value) |
abstract <L> IEither<L,T> |
toEither(ISupplier<L> ifNone) |
abstract java.util.List<T> |
toList() |
@NotNull public abstract java.util.List<T> toList()
@Nullable public abstract T orNull()
null if this option is IOption.None.null if this option is IOption.None.@NotNull public abstract T get()
IOption.None.java.lang.IllegalStateException - if this option is IOption.None.public abstract boolean isEmpty()
public boolean isDefined()
@NotNull public abstract IOption<T> filter(@NotNull IFunction<? super T,java.lang.Boolean> fn)
@NotNull public abstract <R> IOption<R> flatMap(@NotNull IFunction<? super T,IOption<R>> fn)
@NotNull public java.util.Iterator<T> iterator()
iterator in interface java.lang.Iterable<T>@NotNull public static <R> IOption<R> some(@NotNull R value)
@NotNull public static <R> IOption<R> none()
@NotNull public static <R> IOption<R> ofNullable(@Nullable R value)