T - the value typepublic final class Try<T>
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object other) |
java.lang.Throwable |
error()
Returns the error or null if this Try holds a value instead.
|
boolean |
hasError()
Returns true if this Try holds an error.
|
int |
hashCode() |
boolean |
hasValue()
Returns true if this Try holds a value.
|
static <T> Try<T> |
ofError(java.lang.Throwable e)
Constructs a Try instance by wrapping the given Throwable.
|
static <T> Try<T> |
ofValue(T value)
Constructs a Try instance by wrapping the given value.
|
java.lang.String |
toString() |
T |
value()
Returns the value or null if the value is actually null or if this Try holds an error instead.
|
public static <T> Try<T> ofValue(T value)
T - the value typevalue - the value to wrappublic static <T> Try<T> ofError(java.lang.Throwable e)
Null Throwables are replaced by NullPointerException instance in this Try.
T - the value typee - the exception to wrappublic T value()
hasValue()public java.lang.Throwable error()
public boolean hasError()
public boolean hasValue()
public boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object