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
An immutable container representing an intermediate or final result produced by
executing a
Task
, typically by an individual Executor
, including no
result, a specific value or a Throwable
.
If a value or Throwable
is present, isPresent() will return true
and get() will return the value or throw the Throwable
.
- Since:
- 21.12
- Author:
- bo
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
get()
Obtains the value throwable theResult
.int
hashCode()
boolean
boolean
boolean
isValue()
Determines if the value is available (includingnull
).static <T> Result
<T> none()
Constructs anResult
representing no value.static <T> Result
<T> of
(T value) Constructs anResult
with a specific value.Obtains the value of theResult
if present, otherwise returns the specified value.void
Restore the contents of a user type instance by reading its state using the specified PofReader object.void
Restore the contents of this object by loading the object's state from the passed DataInput object.static Result
toString()
void
writeExternal
(PofWriter out) Save the contents of a POF user type instance by writing its state using the specified PofWriter object.void
writeExternal
(DataOutput out) Save the contents of this object by storing the object's state into the passed DataOutput object.
-
Field Details
-
m_fPresent
protected boolean m_fPresentIs the result present? -
m_value
The value (when provided). -
m_throwable
The throwable (when error occurred).
-
-
Constructor Details
-
Result
public Result()Constructs anResult
that has no value.
-
-
Method Details
-
none
Constructs anResult
representing no value. -
of
Constructs anResult
with a specific value. -
throwable
-
isPresent
public boolean isPresent() -
isValue
public boolean isValue()Determines if the value is available (includingnull
). -
isThrowable
public boolean isThrowable() -
get
Obtains the value throwable theResult
.- Returns:
- the value throwable the
Result
- Throws:
NoSuchElementException
- when theResult
value is notisPresent()
Throwable
- when theResult
was any otherThrowable
-
orElse
Obtains the value of theResult
if present, otherwise returns the specified value.- Parameters:
value
- the value to return if theisPresent()
fails- Returns:
- the
get()
whenisPresent()
, otherwise the specified value
-
equals
-
hashCode
public int hashCode() -
toString
-
readExternal
Description copied from interface:ExternalizableLite
Restore the contents of this object by loading the object's state from the passed DataInput object.- Specified by:
readExternal
in 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 occurs
-
writeExternal
Description copied from interface:ExternalizableLite
Save the contents of this object by storing the object's state into the passed DataOutput object.- Specified by:
writeExternal
in interfaceExternalizableLite
- Parameters:
out
- the DataOutput stream to write the state of this object to- Throws:
IOException
- if an I/O exception occurs
-
readExternal
Description copied from interface:PortableObject
Restore the contents of a user type instance by reading its state using the specified PofReader object.- Specified by:
readExternal
in interfacePortableObject
- Parameters:
in
- the PofReader from which to read the object's state- Throws:
IOException
- if an I/O error occurs
-
writeExternal
Description copied from interface:PortableObject
Save the contents of a POF user type instance by writing its state using the specified PofWriter object.- Specified by:
writeExternal
in interfacePortableObject
- Parameters:
out
- the PofWriter to which to write the object's state- Throws:
IOException
- if an I/O error occurs
-