-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classTry.Companionpublic final classTry.Successpublic final classTry.Failure
-
Method Summary
Modifier and Type Method Description abstract BooleanisSuccess()abstract BooleanisFailure()abstract SuccessgetOrThrow()Returns the encapsulated value if this instance represents success or throws the encapsulated Throwable exception if it is failure. abstract SuccessgetOrNull()Returns the encapsulated value if this instance represents success or null if it is failure. abstract FailureexceptionOrNull()Returns the encapsulated Throwable exception if this instance represents failure or null if it is success. final <R extends Any> Try<R, Failure>map(Function1<Success, R> transform)Returns the encapsulated result of the given transform function applied to the encapsulated value if this instance represents success or the original encapsulated Throwable exception if it is failure. final <F extends Throwable> Try<Success, F>mapFailure(Function1<Failure, F> transform)Returns the encapsulated result of the given transform function applied to the encapsulated failure if this instance represents failure or the original encapsulated success value if it is a success. final <R extends Any> Rfold(Function1<Success, R> onSuccess, Function1<Throwable, R> onFailure)Returns the result of onSuccess for the encapsulated value if this instance represents success or the result of onFailure function for the encapsulated Throwable exception if it is failure. final Try<Success, Failure>onSuccess(Function1<Success, Unit> action)Performs the given action on the encapsulated value if this instance represents success. final Try<Success, Failure>onFailure(Function1<Failure, Unit> action)Performs the given action on the encapsulated Throwable exception if this instance represents failure. -
-
Method Detail
-
getOrThrow
abstract Success getOrThrow()
Returns the encapsulated value if this instance represents success or throws the encapsulated Throwable exception if it is failure.
-
getOrNull
abstract Success getOrNull()
Returns the encapsulated value if this instance represents success or null if it is failure.
-
exceptionOrNull
abstract Failure exceptionOrNull()
Returns the encapsulated Throwable exception if this instance represents failure or null if it is success.
-
map
final <R extends Any> Try<R, Failure> map(Function1<Success, R> transform)
Returns the encapsulated result of the given transform function applied to the encapsulated value if this instance represents success or the original encapsulated Throwable exception if it is failure.
-
mapFailure
final <F extends Throwable> Try<Success, F> mapFailure(Function1<Failure, F> transform)
Returns the encapsulated result of the given transform function applied to the encapsulated failure if this instance represents failure or the original encapsulated success value if it is a success.
-
fold
final <R extends Any> R fold(Function1<Success, R> onSuccess, Function1<Throwable, R> onFailure)
-
onSuccess
final Try<Success, Failure> onSuccess(Function1<Success, Unit> action)
Performs the given action on the encapsulated value if this instance represents success. Returns the original Try unchanged.
-
-
-
-