Class Payload

java.lang.Object
io.axoniq.framework.workflow.dsl.api.Payload

public class Payload extends Object
Payload manipulation helper.
Since:
5.4.0
Author:
Simon Zambrovski
  • Field Details

    • PAYLOAD_TYPE

      public static final com.fasterxml.jackson.core.type.TypeReference<Map<String,@Nullable Object>> PAYLOAD_TYPE
      Map type reference for easy access.
  • Constructor Details

    • Payload

      public Payload(Map<String,@Nullable Object> payload)
      Constructs a new payload around the given map.
      Parameters:
      payload - payload map.
  • Method Details

    • payload

      public static Payload payload(ProcessingContext processingContext, Object value)
      Constructs a new payload around the given value, converting it using the given processing context.
      Parameters:
      processingContext - processing context for the current workflow invocation
      value - payload value.
      Returns:
      payload representation of the given value.
    • payload

      public static Payload payload(Map<String,@Nullable Object> payload)
      Constructs a new payload around the given value.
      Parameters:
      payload - payload value.
      Returns:
      payload representation of the given value.
    • payload

      public static Payload payload()
      Constructs a new empty payload.
      Returns:
      empty payload.
    • payload

      public static Payload payload(String key, @Nullable Object value)
      Constructs a new payload with a single key-value pair.
      Parameters:
      key - property name.
      value - value
      Returns:
      payload with one value.
    • payload

      public static Payload payload(String key, @Nullable Object value, String key2, @Nullable Object value2)
      Constructs a new payload with two key-value pairs.
      Parameters:
      key - property name for the first value.
      value - first value.
      key2 - property key for the second value.
      value2 - second value.
      Returns:
      payload with two values.
    • payload

      public static Payload payload(String key, @Nullable Object value, String key2, @Nullable Object value2, String key3, @Nullable Object value3)
      Constructs a new payload with three key-value pairs.
      Parameters:
      key - property name for the first value.
      value - first value.
      key2 - property key for the second value.
      value2 - second value.
      key3 - property key for the third value.
      value3 - third value.
      Returns:
      payload with three values.
    • get

      public <T> @Nullable T get(String key)
      Retrieves a value from the payload by key.
      Type Parameters:
      T - type of the value to retrieve.
      Parameters:
      key - property key to retrieve.
      Returns:
      value associated with the key.
    • getPayloadAs

      public <T> @Nullable T getPayloadAs(String key, Function<Map<String,@Nullable Object>,T> converter)
      Retrieves a value from the payload by key and converts it using the given converter.
      Type Parameters:
      T - type of return value.
      Parameters:
      key - property name.
      converter - converter to use.
      Returns:
      converter payload.
    • set

      public Payload set(String key, @Nullable Object value)
      Sets a value in the payload.
      Parameters:
      key - property key.
      value - value to set.
      Returns:
      payload with updated value.
    • with

      public Payload with(Payload other)
      Merges another payload into this payload.
      Parameters:
      other - payload to merge.
      Returns:
      payload with merged values.
    • with

      public Payload with(String key, @Nullable Object value)
      Fluent payload builder.
      Parameters:
      key - property key.
      value - value.
      Returns:
      payload with updated value.
    • getValues

      public Map<String,@Nullable Object> getValues()
      Retrieves the underlying payload map.
      Returns:
      payload map.