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:
ExternalizableLite,PortableObject,Serializable
public class Result<T> extends Object implements ExternalizableLite, 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(PofReader in)Restore the contents of a user type instance by reading its state using the specified PofReader object.voidreadExternal(DataInput in)Restore the contents of this object by loading the object's state from the passed DataInput object.static Resultthrowable(Throwable throwable)StringtoString()voidwriteExternal(PofWriter out)Save the contents of a POF user type instance by writing its state using the specified PofWriter object.voidwriteExternal(DataOutput out)Save the contents of this object by storing the object's state into the passed DataOutput object.
-
-
-
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
Description copied from interface:ExternalizableLiteRestore the contents of this object by loading the object's state from the passed DataInput object.- Specified by:
readExternalin interfaceExternalizableLite- Parameters:
in- the DataInput stream to read data from in order to restore the state of this object- Throws:
IOException- if an I/O exception occursNotActiveException- if the object is not in its initial state, and therefore cannot be deserialized into
-
writeExternal
public void writeExternal(DataOutput out) throws IOException
Description copied from interface:ExternalizableLiteSave the contents of this object by storing the object's state into the passed DataOutput object.- Specified by:
writeExternalin interfaceExternalizableLite- Parameters:
out- the DataOutput stream to write the state of this object to- Throws:
IOException- if an I/O exception occurs
-
readExternal
public void readExternal(PofReader in) throws IOException
Description copied from interface:PortableObjectRestore the contents of a user type instance by reading its state using the specified PofReader object.- Specified by:
readExternalin interfacePortableObject- Parameters:
in- the PofReader from which to read the object's state- Throws:
IOException- if an I/O error occurs
-
writeExternal
public void writeExternal(PofWriter out) throws IOException
Description copied from interface:PortableObjectSave the contents of a POF user type instance by writing its state using the specified PofWriter object.- Specified by:
writeExternalin interfacePortableObject- Parameters:
out- the PofWriter to which to write the object's state- Throws:
IOException- if an I/O error occurs
-
-