Package kos.core
Class Lang.Result<T>
- java.lang.Object
-
- kos.core.Lang.Result<T>
-
-
Field Summary
Fields Modifier and Type Field Description (package private) RuntimeExceptioncause(package private) Tdata
-
Constructor Summary
Constructors Constructor Description Result()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> Lang.Result<T>empty()booleanfailed()static <T,E extends RuntimeException>
Lang.Result<T>failure(E cause)Tget()booleanisEmpty()booleanisPresent()<R> Lang.Result<R>map(Function<T,R> mapper)static <T> Lang.Result<T>of(T value)TorElse(T other)TorElseGet(Function<RuntimeException,T> other)TorElseGet(Supplier<T> other)<E extends RuntimeException>
TorElseThrow(Supplier<E> cause)
-
-
-
Field Detail
-
cause
final RuntimeException cause
-
data
final T data
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
-
isPresent
public boolean isPresent()
-
failed
public boolean failed()
-
get
public T get()
-
orElseThrow
public <E extends RuntimeException> T orElseThrow(Supplier<E> cause)
-
orElseGet
public T orElseGet(Function<RuntimeException,T> other)
-
map
public <R> Lang.Result<R> map(Function<T,R> mapper)
-
failure
public static <T,E extends RuntimeException> Lang.Result<T> failure(E cause)
-
of
public static <T> Lang.Result<T> of(T value)
-
empty
public static <T> Lang.Result<T> empty()
-
-