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.Constructor and Description |
---|
MethodResult(DataValue output,
ErrorValue error)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
ErrorValue |
getError()
Returns the error for this
MethodResult . |
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) |
boolean |
success()
Returns
true if the invoked method completed
successfully, i.e. |
java.lang.String |
toString() |
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
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 null
public DataValue getOutput()
public ErrorValue getError()
MethodResult
.public 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 java.lang.String toString()
toString
in class java.lang.Object
public 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)