Record Class Event

java.lang.Object
java.lang.Record
io.umadb.client.Event

public record Event(String type, List<String> tags, byte[] data, UUID id) 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, and a unique event identifier.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Event(String type, List<String> tags, byte[] data, UUID id)
    Creates a new Event.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Returns the value of the data record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    id()
    Returns the value of the id record component.
    static Event
    of(String type, String tag, byte[] data)
    Creates a new Event with a generated identifier and a single tag.
    static Event
    of(String type, List<String> tags, byte[] data)
    Creates a new Event with a generated identifier.
    Returns the value of the tags record component.
    final String
    Returns a string representation of this record class.
    Returns the value of the type record component.
    static Event
    withId(String type, List<String> tags, byte[] data, UUID id)
    Creates a new Event with the given identifier.
    Returns a copy of this event with a different identifier.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

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