-
public final class TryKt
-
-
Method Summary
Modifier and Type Method Description final static <S extends Any, F extends Throwable> SgetOrThrow(Try<S, F> $self)Returns the encapsulated value if this instance represents success or throws the encapsulated Throwable exception if it is failure. final static <S extends Any, F extends Error> SgetOrThrowError(Try<S, F> $self)Returns the encapsulated value if this instance represents success or throws the encapsulated ThrowableError exception if it is failure. final static <R extends Any, S extends R, F extends Any> RgetOrDefault(Try<S, F> $self, R defaultValue)Returns the encapsulated value if this instance represents success or the defaultValue if it is failure. final static <R extends Any, S extends R, F extends Any> RgetOrElse(Try<S, F> $self, Function1<F, R> onFailure)Returns the encapsulated value if this instance represents success or the result of onFailure function for the encapsulated value if it is failure. final static <R extends Any, S extends Any, F extends Any> Try<R, F>flatMap(Try<S, F> $self, Function1<S, Try<R, F>> transform)Returns the encapsulated result of the given transform function applied to the encapsulated value if this instance represents success or the original encapsulated value if it is failure. final static <R extends Any, S extends R, F extends Any, T extends Any> Try<R, T>tryRecover(Try<S, F> $self, Function1<F, Try<R, T>> transform)Returns the encapsulated result of the given transform function applied to the encapsulated value if this instance represents failure or the original encapsulated value if it is success. final static <S extends Any, F extends Any> ScheckSuccess(Try<S, F> $self)Returns value in case of success and throws an IllegalStateException in case of failure. -
-
Method Detail
-
getOrThrow
final static <S extends Any, F extends Throwable> S getOrThrow(Try<S, F> $self)
Returns the encapsulated value if this instance represents success or throws the encapsulated Throwable exception if it is failure.
-
getOrThrowError
@Deprecated(message = An `Error` is not a throwable object. Refactor or wrap in an `ErrorException`., replaceWith = @ReplaceWith(imports = {}, expression = getOrElse { throw ErrorException(it) }), level = DeprecationLevel.ERROR) final static <S extends Any, F extends Error> S getOrThrowError(Try<S, F> $self)
Returns the encapsulated value if this instance represents success or throws the encapsulated ThrowableError exception if it is failure.
-
getOrDefault
final static <R extends Any, S extends R, F extends Any> R getOrDefault(Try<S, F> $self, R defaultValue)
Returns the encapsulated value if this instance represents success or the defaultValue if it is failure.
-
getOrElse
final static <R extends Any, S extends R, F extends Any> R getOrElse(Try<S, F> $self, Function1<F, R> onFailure)
Returns the encapsulated value if this instance represents success or the result of onFailure function for the encapsulated value if it is failure.
-
flatMap
final static <R extends Any, S extends Any, F extends Any> Try<R, F> flatMap(Try<S, F> $self, Function1<S, Try<R, F>> transform)
Returns the encapsulated result of the given transform function applied to the encapsulated value if this instance represents success or the original encapsulated value if it is failure.
-
tryRecover
final static <R extends Any, S extends R, F extends Any, T extends Any> Try<R, T> tryRecover(Try<S, F> $self, Function1<F, Try<R, T>> transform)
Returns the encapsulated result of the given transform function applied to the encapsulated value if this instance represents failure or the original encapsulated value if it is success.
-
checkSuccess
final static <S extends Any, F extends Any> S checkSuccess(Try<S, F> $self)
Returns value in case of success and throws an IllegalStateException in case of failure.
-
-
-
-