Class Result<T,A>

java.lang.Object
org.mule.sdk.api.runtime.operation.Result<T,A>
Type Parameters:
T - the generic type of the output value
A - the generic type of the message attributes

@MinMuleVersion("4.4") public class Result<T,A> extends Object
Represents the result of a component's execution. Extensions can use this class for cases in which the component not only needs to return a value to be set on the message payload but also wants to specify message attributes and/or MediaType.

The getOutput() value is always taken at face value, meaning that if it's null, then the value that the operation returns to the runtime will in fact be null. However, if the getAttributes() or getMediaType() are Optional.empty(), then the runtime will interpret that as the operation not interested in setting those values, keeping the input message's attributes and/or media type untouched.

Since:
1.0
  • Constructor Details

    • Result

      protected Result()
  • Method Details

    • builder

      public static <T, A> Result.Builder<T,A> builder()
      Creates a new Result.Builder
      Type Parameters:
      T - the generic type of the output value
      A - the generic type of the message attributes
      Returns:
      a new Result.Builder
    • builder

      public static <T, A> Result.Builder<T,A> builder(org.mule.runtime.api.message.Message muleMessage)
      Creates a new Result.Builder initialises with a state that matched the one of the given muleMessage
      Type Parameters:
      T - the generic type of the output value
      A - the generic type of the message attributes
      Parameters:
      muleMessage - a reference Message
      Returns:
      a new Result.Builder
    • copy

      public Result.Builder<T,A> copy()
      Creates a new Result.Builder initialises with a state that matched this result
      Returns:
      a new Result.Builder
    • getOutput

      public T getOutput()
      Returns:
      The operation's output
    • getAttributes

      public Optional<A> getAttributes()
      The new value that the operation wants to set on Message.getAttributes().

      The operation might not be interested in changing that value, in which case this method would return Optional.empty()

      Returns:
      an Optional Attributes value
    • getMediaType

      public Optional<org.mule.runtime.api.metadata.MediaType> getMediaType()
      The new MediaType that the operation wants to set on Message payload.

      The operation might not be interested in changing that value, in which case this method would return Optional.empty()

      Returns:
      an Optional MediaType value
    • getByteLength

      public OptionalLong getByteLength()
      The length of the payload in bytes if known.
      Returns:
      an Optional payload length
    • getAttributesMediaType

      public Optional<org.mule.runtime.api.metadata.MediaType> getAttributesMediaType()
      The new MediaType that the operation wants to set on Message attributes.

      The operation might not be interested in changing that value, in which case this method would return Optional.empty()

      Returns:
      an Optional MediaType value