public class RuntimeActionResult extends Object
This class stores the raw result of a given computation, and can be initialized with additional information
representing the execution time, and the Exception
thrown by the computation.
RuntimeActionResult
provides an isError()
method that returns true
if it contains an
Exception
. This allows to quickly check whether the underlying computation succeeded or failed.
Constructor and Description |
---|
RuntimeActionResult(Object partialResult,
Exception thrownException,
long executionTime)
Constructs a new
RuntimeActionResult from the provided partialResult , thrownException ,
and executionTime . |
RuntimeActionResult(Object result,
long executionTime)
|
Modifier and Type | Method and Description |
---|---|
long |
getExecutionTime()
Returns the execution time value (in milliseconds) stored in this
RuntimeActionResult . |
Object |
getResult()
Returns the raw result stored in this
RuntimeActionResult . |
Exception |
getThrownException()
Return the
Exception that has been thrown during the computation. |
boolean |
isError()
Returns whether the
RuntimeActionResult represents an errored computation. |
public RuntimeActionResult(Object result, long executionTime)
RuntimeActionResult
from the provided result
and executionTime
.
This constructor does not set any thrownException
value. As a result, calling the isError()
method will return false
.
result
- the raw resultexecutionTime
- the execution time (in milliseconds)IllegalArgumentException
- if the provided executionTime < 0
public RuntimeActionResult(Object partialResult, Exception thrownException, long executionTime)
RuntimeActionResult
from the provided partialResult
, thrownException
,
and executionTime
.
This constructor sets the thrownException
attribute, meaning that calling isError()
on this
object will return true
. The partialResult
can be used to represent partial information that
has been computed before the provided Exception
was thrown.
This constructor sets the executionTime
attribute, that can be accessed through the
getExecutionTime()
method.
partialResult
- the partial raw result that has been computed before failingthrownException
- the Exception
that has been thrown during the computationexecutionTime
- the execution time (in milliseconds)IllegalArgumentException
- if the provided executionTime < 0
public Object getResult()
RuntimeActionResult
.RuntimeActionResult
public long getExecutionTime()
RuntimeActionResult
.RuntimeActionResult
public Exception getThrownException()
Exception
that has been thrown during the computation.
If this value is null
, the isError()
method returns false
, meaning that this
RuntimeActionResult
does not represent an errored computation. If the isError()
method returns
true
that Exception
that has been thrown during the errored computation can be retrieved
through this method.
public boolean isError()
RuntimeActionResult
represents an errored computation.
If this method returns true
the Exception
that has been thrown during the errored computation
can be retrieved by calling getThrownException()
.
true
if the RuntimeActionResult
represents an errored computation, false
otherwisegetThrownException()
Copyright © 2020 SOM Research Lab. All rights reserved.