Package org.apache.flink.util
Class OptionalFailure<T>
- java.lang.Object
-
- org.apache.flink.util.OptionalFailure<T>
-
- All Implemented Interfaces:
Serializable
public class OptionalFailure<T> extends Object implements Serializable
Wrapper around an object representing either a success (with a given value) or a failure cause.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> OptionalFailure<T>
createFrom(CheckedSupplier<T> valueSupplier)
boolean
equals(Object obj)
T
get()
Throwable
getFailureCause()
T
getUnchecked()
int
hashCode()
boolean
isFailure()
static <T> OptionalFailure<T>
of(T value)
static <T> OptionalFailure<T>
ofFailure(Throwable failureCause)
String
toString()
-
-
-
Method Detail
-
of
public static <T> OptionalFailure<T> of(T value)
-
ofFailure
public static <T> OptionalFailure<T> ofFailure(Throwable failureCause)
-
createFrom
public static <T> OptionalFailure<T> createFrom(CheckedSupplier<T> valueSupplier)
- Returns:
- wrapped
OptionalFailure
returned byvalueSupplier
or wrapped failure ifvalueSupplier
has thrown anException
.
-
get
public T get() throws FlinkException
- Returns:
- stored value or throw a
FlinkException
withfailureCause
. - Throws:
FlinkException
-
getUnchecked
public T getUnchecked() throws FlinkRuntimeException
- Returns:
- same as
get()
but throws aFlinkRuntimeException
. - Throws:
FlinkRuntimeException
-
getFailureCause
public Throwable getFailureCause()
-
isFailure
public boolean isFailure()
-
-