Class ImmutableMessageRecordValue

java.lang.Object
io.camunda.zeebe.protocol.record.value.ImmutableMessageRecordValue
All Implemented Interfaces:
JsonSerializable, RecordValue, RecordValueWithVariables, MessageRecordValue

@ParametersAreNonnullByDefault @Immutable public final class ImmutableMessageRecordValue extends Object implements MessageRecordValue
Immutable implementation of MessageRecordValue.

Use the builder to create immutable instances: ImmutableMessageRecordValue.builder().

  • Method Details

    • getVariables

      public Map<String,Object> getVariables()
      Specified by:
      getVariables in interface RecordValueWithVariables
      Returns:
      the variables of this record. Can be empty.
    • getName

      public String getName()
      Specified by:
      getName in interface MessageRecordValue
      Returns:
      the name of the message
    • getCorrelationKey

      public String getCorrelationKey()
      Specified by:
      getCorrelationKey in interface MessageRecordValue
      Returns:
      the correlation key of the message
    • getMessageId

      public String getMessageId()
      The ID of a message is an optional field which is used to make messages unique and prevent publishing the same message twice during its lifetime.
      Specified by:
      getMessageId in interface MessageRecordValue
      Returns:
      the id of the message
    • getTimeToLive

      public long getTimeToLive()
      Specified by:
      getTimeToLive in interface MessageRecordValue
      Returns:
      the time to live of the message
    • getDeadline

      public long getDeadline()
      Specified by:
      getDeadline in interface MessageRecordValue
      Returns:
      the unix timestamp in milliseconds until when the message can be correlated. If the deadline is exceeded then the message expires and will be removed. If this property is not set, it returns -1 instead.
    • withVariables

      public final ImmutableMessageRecordValue withVariables(Map<String,? extends Object> entries)
      Copy the current immutable object by replacing the variables map with the specified map. Nulls are not permitted as keys or values. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      entries - The entries to be added to the variables map
      Returns:
      A modified copy of this object
    • withName

      public final ImmutableMessageRecordValue withName(String value)
      Copy the current immutable object by setting a value for the name attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for name (can be null)
      Returns:
      A modified copy of the this object
    • withCorrelationKey

      public final ImmutableMessageRecordValue withCorrelationKey(String value)
      Copy the current immutable object by setting a value for the correlationKey attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for correlationKey (can be null)
      Returns:
      A modified copy of the this object
    • withMessageId

      public final ImmutableMessageRecordValue withMessageId(String value)
      Copy the current immutable object by setting a value for the messageId attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for messageId (can be null)
      Returns:
      A modified copy of the this object
    • withTimeToLive

      public final ImmutableMessageRecordValue withTimeToLive(long value)
      Copy the current immutable object by setting a value for the timeToLive attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for timeToLive
      Returns:
      A modified copy of the this object
    • withDeadline

      public final ImmutableMessageRecordValue withDeadline(long value)
      Copy the current immutable object by setting a value for the deadline attribute. A value equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for deadline
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(@Nullable Object another)
      This instance is equal to all instances of ImmutableMessageRecordValue that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • hashCode

      public int hashCode()
      Returns a lazily computed hash code from attributes: variables, name, correlationKey, messageId, timeToLive, deadline.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value MessageRecordValue with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • copyOf

      public static ImmutableMessageRecordValue copyOf(MessageRecordValue instance)
      Creates an immutable copy of a MessageRecordValue value. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.
      Parameters:
      instance - The instance to copy
      Returns:
      A copied immutable MessageRecordValue instance
    • builder

      public static ImmutableMessageRecordValue.Builder builder()
      Creates a builder for ImmutableMessageRecordValue.
       ImmutableMessageRecordValue.builder()
          .putVariable|putAllVariables(String => Object) // variables mappings
          .withName(String | null) // nullable name
          .withCorrelationKey(String | null) // nullable correlationKey
          .withMessageId(String | null) // nullable messageId
          .withTimeToLive(long) // optional timeToLive
          .withDeadline(long) // optional deadline
          .build();
       
      Returns:
      A new ImmutableMessageRecordValue builder