Record Class Tag

java.lang.Object
java.lang.Record
org.axonframework.messaging.eventstreaming.Tag
Record Components:
key - The key of this Tag.
value - The value of this Tag.

public record Tag(@Nonnull String key, @Nonnull String value) extends Record
An Tag refers to fields and their values within which an EventMessage has been published, typically referring to domain-specifics used for identification.

Such a Tag is typically used by the EventCriteria as a filter when sourcing, streaming or appending events.

Since:
5.0.0
Author:
Allard Buijze, Michal Negacz, Milan Savić, Marco Amann, Sara Pellegrini, Steven van Beelen
  • Field Details

  • Constructor Details

    • Tag

      public Tag(@Nonnull String key, @Nonnull String value)
      Compact constructor validating that the given key and value are not null.
  • Method Details

    • addToContext

      public static Context addToContext(Context context, Set<Tag> tags)
      Adds the given token to the given context using the RESOURCE_KEY.
      Parameters:
      context - The Context to add the given token to.
      tags - The Set of Tags to add to the given context using the RESOURCE_KEY.
    • fromContext

      public static Optional<Set<Tag>> fromContext(Context context)
      Returns an Optional of Tags, returning the resource keyed under the RESOURCE_KEY in the given context.
      Parameters:
      context - The Context to retrieve the Tags from, if present.
      Returns:
      An Optional of Tags, returning the resource keyed under the RESOURCE_KEY in the given context.
    • of

      public static Tag of(@Nonnull String key, @Nonnull String value)
      Creates a new Tag with the given key and value.
      Parameters:
      key - The key of the new Tag.
      value - The value of the new Tag.
      Returns:
      A new Tag with the given key and value.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • key

      @Nonnull public String key()
      Returns the value of the key record component.
      Returns:
      the value of the key record component
    • value

      @Nonnull public String value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component