Class Result<T>
- java.lang.Object
-
- com.oracle.coherence.concurrent.executor.Result<T>
-
- Type Parameters:
T- the type of result produced by theTask
- All Implemented Interfaces:
com.tangosol.io.ExternalizableLite,com.tangosol.io.pof.PortableObject,Serializable
public class Result<T> extends Object implements com.tangosol.io.ExternalizableLite, com.tangosol.io.pof.PortableObject
An immutable container representing an intermediate or final result produced by executing aTask, typically by an individualExecutor, including no result, a specific value or aThrowable.If a value or
Throwableis present, isPresent() will returntrueand get() will return the value or throw theThrowable.- Since:
- 21.12
- Author:
- bo
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanm_fPresentIs the result present?protected Throwablem_throwableThe throwable (when error occurred).protected Tm_valueThe value (when provided).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)Tget()Obtains the value throwable theResult.inthashCode()booleanisPresent()booleanisThrowable()booleanisValue()Determines if the value is available (includingnull).static <T> Result<T>none()Constructs anResultrepresenting no value.static <T> Result<T>of(T value)Constructs anResultwith a specific value.TorElse(T value)Obtains the value of theResultif present, otherwise returns the specified value.voidreadExternal(com.tangosol.io.pof.PofReader in)voidreadExternal(DataInput in)static Resultthrowable(Throwable throwable)StringtoString()voidwriteExternal(com.tangosol.io.pof.PofWriter out)voidwriteExternal(DataOutput out)
-
-
-
Constructor Detail
-
Result
public Result()
Constructs anResultthat has no value.
-
-
Method Detail
-
isValue
public boolean isValue()
Determines if the value is available (includingnull).
-
isThrowable
public boolean isThrowable()
-
get
public T get() throws Throwable
Obtains the value throwable theResult.- Returns:
- the value throwable the
Result - Throws:
NoSuchElementException- when theResultvalue is notisPresent()Throwable- when theResultwas any otherThrowable
-
orElse
public T orElse(T value)
Obtains the value of theResultif present, otherwise returns the specified value.- Parameters:
value- the value to return if theisPresent()fails- Returns:
- the
get()whenisPresent(), otherwise the specified value
-
readExternal
public void readExternal(DataInput in) throws IOException
- Specified by:
readExternalin interfacecom.tangosol.io.ExternalizableLite- Throws:
IOException
-
writeExternal
public void writeExternal(DataOutput out) throws IOException
- Specified by:
writeExternalin interfacecom.tangosol.io.ExternalizableLite- Throws:
IOException
-
readExternal
public void readExternal(com.tangosol.io.pof.PofReader in) throws IOException- Specified by:
readExternalin interfacecom.tangosol.io.pof.PortableObject- Throws:
IOException
-
writeExternal
public void writeExternal(com.tangosol.io.pof.PofWriter out) throws IOException- Specified by:
writeExternalin interfacecom.tangosol.io.pof.PortableObject- Throws:
IOException
-
-