Modifier and Type | Method and Description |
---|---|
static <V> Try<V> |
failure(String message) |
static <V> Try<V> |
failure(String message,
Throwable e) |
static <V> Try<V> |
failure(Throwable e)
If you need type coercion, you should call this method as
Try.
|
<U> Try<U> |
flatMap(Function<? super V,Try<U>> fn)
This is the bind method.
|
abstract V |
get()
Returns the value if this is a success instance.
|
abstract Throwable |
getError()
Returns the throwable that is stored in the failure.
|
abstract Boolean |
isFailure() |
abstract Boolean |
isSuccess() |
<U> Try<U> |
map(Function<? super V,U> fn)
A mapping method for mapping the current instance to a new type.
|
static <V> Try<V> |
success(V value)
Returns a instance for the success case.
|
abstract void |
throwException() |
String |
toString() |
public abstract void throwException()
public abstract V get()
public abstract Throwable getError()
public <U> Try<U> map(Function<? super V,U> fn)
U
- fn
- public <U> Try<U> flatMap(Function<? super V,Try<U>> fn)
U
- fn
- public static <V> Try<V> failure(Throwable e)
V
- The generic type this monad keepse
- The exception that is thrownpublic static <V> Try<V> success(V value)
V
- The return typevalue
- The value that should be stored.Copyright © 2006–2019 The Apache Software Foundation. All rights reserved.