Class MethodResult


  • public class MethodResult
    extends java.lang.Object
    The 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 Detail

      • MethodResult

        public MethodResult​(DataValue output,
                            ErrorValue error)
        Constructor. Creates an instance that is associated with 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

        Parameters:
        error - the error to associate with this result
        output - the return value to associate with this result
        Throws:
        java.lang.IllegalArgumentException - if output and error are both null, or are both not null
      • MethodResult

        public MethodResult​(DataValue output,
                            ErrorValue error,
                            Consumer<AsyncHandle<MethodResult>> next)
        Constructor. Creates an instance that is associated with 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

        Parameters:
        error - the error to associate with this result
        output - the return value to associate with this result
        next - the next handle consumer
        Throws:
        java.lang.IllegalArgumentException - if output and error are both null, or are both not null
    • 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 this MethodResult.
        Returns:
        the error or null if there is none
      • success

        public boolean success()
        Returns true 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
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • newResult

        public static MethodResult newResult​(DataValue output)
        Static factory method for creating MethodResult 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 creating MethodResult instance for error reported by method invocation
        Parameters:
        error - the error reported by method
        Returns:
        new MethodResult instance
        See Also:
        MethodResult(DataValue, ErrorValue)