public class MethodResult
extends java.lang.Object
MethodResult class contains the result of a method
call. It contains either the output of the method invocation or
an error reported by the method invocation. These are mutually
exclusive.| Modifier and Type | Field and Description |
|---|---|
static MethodResult |
EMPTY |
| Constructor and Description |
|---|
MethodResult(DataValue output,
ErrorValue error)
Constructor.
|
MethodResult(DataValue output,
ErrorValue error,
Consumer<AsyncHandle<MethodResult>> next)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
ErrorValue |
getError()
Returns the error for this
MethodResult. |
Consumer<AsyncHandle<MethodResult>> |
getNext()
Returns the handle to receive the next
AsyncHandle or
null. |
DataValue |
getOutput()
Returns the output of the method call.
|
static MethodResult |
newErrorResult(ErrorValue error)
Static factory method for creating
MethodResult instance
for error reported by method invocation |
static MethodResult |
newResult(DataValue output)
Static factory method for creating
MethodResult instance
for normal return value (as opposed to error) |
void |
setNext(Consumer<AsyncHandle<MethodResult>> next)
Sets the
Consumer for the next frame of the result |
boolean |
success()
Returns
true if the invoked method completed
successfully, i.e. |
java.lang.String |
toString() |
public static final MethodResult EMPTY
public MethodResult(DataValue output, ErrorValue error)
DataValue return value or ErrorValue error
result of a method invocation.
Exactly one of output and error must be null
Next handle is set to null
error - the error to associate with this resultoutput - the return value to associate with this resultjava.lang.IllegalArgumentException - if output and error are
both null, or are both not nullpublic MethodResult(DataValue output, ErrorValue error, Consumer<AsyncHandle<MethodResult>> next)
DataValue return value or ErrorValue error
result of a method invocation.
Exactly one of output and error must be null
Next handle allows supplying an AsyncHandle responsible
for handling the following MethodResult. Can be null
error - the error to associate with this resultoutput - the return value to associate with this resultnext - the next handle consumerjava.lang.IllegalArgumentException - if output and error are
both null, or are both not nullpublic DataValue getOutput()
public ErrorValue getError()
MethodResult.public Consumer<AsyncHandle<MethodResult>> getNext()
AsyncHandle or
null.
If the recipient wishes to terminate the connection they ought to pass a
null AsyncHandle to the publisher.
AsyncHandlepublic boolean success()
true if the invoked method completed
successfully, i.e. it hasn't reported an error, but returned
a result.true if the method completed successfullypublic void setNext(Consumer<AsyncHandle<MethodResult>> next)
Consumer for the next frame of the resultpublic java.lang.String toString()
toString in class java.lang.Objectpublic static MethodResult newResult(DataValue output)
MethodResult instance
for normal return value (as opposed to error)output - the method return value for created resultMethodResult instanceMethodResult(DataValue, ErrorValue)public static MethodResult newErrorResult(ErrorValue error)
MethodResult instance
for error reported by method invocationerror - the error reported by methodMethodResult instanceMethodResult(DataValue, ErrorValue)