-
-
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 BooleangetIsSuccess()abstract BooleangetIsFailure()abstract SuccessgetOrNull()Returns the encapsulated value if this instance represents success or null if it is failure. abstract FailurefailureOrNull()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 Any> 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<Failure, 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 value 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 value if this instance represents failure. -
-
Method Detail
-
getIsSuccess
abstract Boolean getIsSuccess()
-
getIsFailure
abstract Boolean getIsFailure()
-
getOrNull
abstract Success getOrNull()
Returns the encapsulated value if this instance represents success or null if it is failure.
-
failureOrNull
abstract Failure failureOrNull()
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 Any> 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.
-
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.
-
-
-
-