Package com.vmware.vapi.core
Class MethodResult
- java.lang.Object
-
- com.vmware.vapi.core.MethodResult
-
public class MethodResult extends java.lang.Object
TheMethodResult
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.
-
-
Field Summary
Fields Modifier and Type Field Description static MethodResult
EMPTY
-
Constructor Summary
Constructors Constructor Description MethodResult(DataValue output, ErrorValue error)
Constructor.MethodResult(DataValue output, ErrorValue error, Consumer<AsyncHandle<MethodResult>> next)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ErrorValue
getError()
Returns the error for thisMethodResult
.Consumer<AsyncHandle<MethodResult>>
getNext()
Returns the handle to receive the nextAsyncHandle
ornull
.DataValue
getOutput()
Returns the output of the method call.static MethodResult
newErrorResult(ErrorValue error)
Static factory method for creatingMethodResult
instance for error reported by method invocationstatic MethodResult
newResult(DataValue output)
Static factory method for creatingMethodResult
instance for normal return value (as opposed to error)void
setNext(Consumer<AsyncHandle<MethodResult>> next)
Sets theConsumer
for the next frame of the resultboolean
success()
Returnstrue
if the invoked method completed successfully, i.e.java.lang.String
toString()
-
-
-
Field Detail
-
EMPTY
public static final MethodResult EMPTY
-
-
Constructor Detail
-
MethodResult
public MethodResult(DataValue output, ErrorValue error)
Constructor. Creates an instance that is associated withDataValue
return value orErrorValue
error result of a method invocation.Exactly one of
output
anderror
must benull
Next handle is set to
null
- Parameters:
error
- the error to associate with this resultoutput
- the return value to associate with this result- Throws:
java.lang.IllegalArgumentException
- ifoutput
anderror
are bothnull
, or are both notnull
-
MethodResult
public MethodResult(DataValue output, ErrorValue error, Consumer<AsyncHandle<MethodResult>> next)
Constructor. Creates an instance that is associated withDataValue
return value orErrorValue
error result of a method invocation.Exactly one of
output
anderror
must benull
Next handle allows supplying an
AsyncHandle
responsible for handling the followingMethodResult
. Can benull
- Parameters:
error
- the error to associate with this resultoutput
- the return value to associate with this resultnext
- the next handle consumer- Throws:
java.lang.IllegalArgumentException
- ifoutput
anderror
are bothnull
, or are both notnull
-
-
Method Detail
-
getOutput
public DataValue getOutput()
Returns the output of the method call.- Returns:
- data value returned by the method invocation
-
getError
public ErrorValue getError()
Returns the error for thisMethodResult
.- Returns:
- the error or null if there is none
-
getNext
public Consumer<AsyncHandle<MethodResult>> getNext()
Returns the handle to receive the nextAsyncHandle
ornull
.If the recipient wishes to terminate the connection they ought to pass a
null
AsyncHandle
to the publisher.- Returns:
- handle to receive the next
AsyncHandle
-
success
public boolean success()
Returnstrue
if the invoked method completed successfully, i.e. it hasn't reported an error, but returned a result.- Returns:
true
if the method completed successfully
-
setNext
public void setNext(Consumer<AsyncHandle<MethodResult>> next)
Sets theConsumer
for the next frame of the result
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
newResult
public static MethodResult newResult(DataValue output)
Static factory method for creatingMethodResult
instance for normal return value (as opposed to error)- Parameters:
output
- the method return value for created result- Returns:
- new
MethodResult
instance - See Also:
MethodResult(DataValue, ErrorValue)
-
newErrorResult
public static MethodResult newErrorResult(ErrorValue error)
Static factory method for creatingMethodResult
instance for error reported by method invocation- Parameters:
error
- the error reported by method- Returns:
- new
MethodResult
instance - See Also:
MethodResult(DataValue, ErrorValue)
-
-