Package sk.softec.util
Interface Try<R,E>
- Type Parameters:
R- success return valueE- error return value
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptiondefault Eerror()default Rdefault RgetOrElseGet(Supplier<R> defaultValue) default Rdefault RgetOrThrow(Function<? super E, ? extends ER> errorSupplier) Invokes the specified block and returns thisInvokes the specified block if this Try isTry.Erand returns thisInvokes the specified block if this Try isTry.Okand returns thisdefault booleanisEr()default booleanisOk()default Rresult()runTry(sk.softec.util.ThrowingRunnable block) runTry(sk.softec.util.ThrowingSupplier<T> block)
-
Method Details
-
isOk
default boolean isOk()- Returns:
- true iff this is
Try.Ok
-
isEr
default boolean isEr()- Returns:
- true iff this is
Try.Er
-
result
- Returns:
getOrThrow()
-
error
- Returns:
getOrThrow()
-
ifSuccess
Invokes the specified block if this Try isTry.Okand returns this -
ifError
Invokes the specified block if this Try isTry.Erand returns this -
ifAny
Invokes the specified block and returns this -
map
- Returns:
- try with success mapped by the specified mapper if success (mapper exceptions are not caught)
-
mapError
- Returns:
- try with error mapped by the specified mapper if error (mapper exceptions are not caught)
-
getOrElse
- Returns:
- success value or the specified value if error
-
getOrElseGet
- Returns:
- success value or the specified value if error
-
getOrElseNull
- Returns:
- success value or null if error (when success is nullable null is ambiguous)
-
getOrThrow
-
getOrThrow
-
toFlatTry
- Returns:
- error with all error values if any error or success with all values
-
runTry
-
runTry
-