Record Class Event

java.lang.Object
java.lang.Record
io.umadb.client.Event
Record Components:
type - the domain type or schema identifier of the event
tags - the indexed labels used for filtering; must contain at least one element
data - the serialized event payload
id - the unique event identifier, used for idempotency and deduplication
metadata - additional context not part of the payload; never null, defaulting to an empty map

public record Event(String type, List<String> tags, byte[] data, UUID id, Map<String,String> metadata) extends Record
Represents a single immutable event.

An event consists of a type identifier, one or more tags for classification or querying, an opaque binary payload, a unique event identifier, and optional metadata carrying contextual information that is not part of the payload itself (for example correlation IDs or user agents).

  • Constructor Details

    • Event

      public Event(String type, List<String> tags, byte[] data, UUID id, Map<String,String> metadata)
      Creates a new Event.
      Throws:
      IllegalArgumentException - if validation constraints are violated
    • Event

      public Event(String type, List<String> tags, byte[] data, UUID id)
      Creates a new Event without metadata.
      Parameters:
      type - the event type
      tags - the event tags (must contain at least one element)
      data - the event payload
      id - the event identifier
      Throws:
      IllegalArgumentException - if validation constraints are violated
  • Method Details

    • of

      public static Event of(String type, List<String> tags, byte[] data)
      Creates a new Event with a generated identifier.
      Parameters:
      type - the event type
      tags - the event tags (must contain at least one element)
      data - the event payload
      Returns:
      a new Event with a random UUID
    • of

      public static Event of(String type, String tag, byte[] data)
      Creates a new Event with a generated identifier and a single tag.
      Parameters:
      type - the event type
      tag - the single event tag
      data - the event payload
      Returns:
      a new Event with a random UUID
    • withId

      public static Event withId(String type, List<String> tags, byte[] data, UUID id)
      Creates a new Event with the given identifier.

      This factory is useful when events are reconstructed from persisted storage or received from a remote source.

      Parameters:
      type - the event type
      tags - the event tags
      data - the event payload
      id - the event identifier
      Returns:
      a new Event
    • withId

      public Event withId(UUID id)
      Returns a copy of this event with a different identifier.
      Parameters:
      id - the new event identifier
      Returns:
      a new Event with the given identifier
    • withMetadata

      public Event withMetadata(Map<String,String> metadata)
      Returns a copy of this event carrying the given metadata.
      Parameters:
      metadata - the metadata entries; may be null to clear
      Returns:
      a new Event with the given metadata
    • withMetadata

      public Event withMetadata(String key, String value)
      Returns a copy of this event with a single additional metadata entry.

      An existing entry with the same key is replaced.

      Parameters:
      key - the metadata key
      value - the metadata value
      Returns:
      a new Event including the given entry
      Throws:
      IllegalArgumentException - if key or value is null
    • equals

      public 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.
    • hashCode

      public 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
    • toString

      public 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
    • type

      public String type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • tags

      public List<String> tags()
      Returns the value of the tags record component.
      Returns:
      the value of the tags record component
    • data

      public byte[] data()
      Returns the value of the data record component.
      Returns:
      the value of the data record component
    • id

      public UUID id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • metadata

      public Map<String,String> metadata()
      Returns the value of the metadata record component.
      Returns:
      the value of the metadata record component