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- the indexed labels used for filtering; must contain at least one elementdata- the serialized event payloadid- the unique event identifier, used for idempotency and deduplicationmetadata- additional context not part of the payload; nevernull, 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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]data()Returns the value of thedatarecord component.booleanIndicates whether some other object is "equal to" this one.inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.metadata()Returns the value of themetadatarecord component.static EventCreates a newEventwith a generated identifier and a single tag.static EventCreates a newEventwith a generated identifier.tags()Returns the value of thetagsrecord component.toString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.static EventCreates a newEventwith the given identifier.Returns a copy of this event with a different identifier.withMetadata(String key, String value) Returns a copy of this event with a single additional metadata entry.withMetadata(Map<String, String> metadata) Returns a copy of this event carrying the given metadata.
-
Constructor Details
-
Event
-
Event
Creates a newEventwithout metadata.- Parameters:
type- the event typetags- the event tags (must contain at least one element)data- the event payloadid- the event identifier- Throws:
IllegalArgumentException- if validation constraints are violated
-
-
Method Details
-
of
-
of
-
withId
Creates a newEventwith the given identifier.This factory is useful when events are reconstructed from persisted storage or received from a remote source.
- Parameters:
type- the event typetags- the event tagsdata- the event payloadid- the event identifier- Returns:
- a new
Event
-
withId
-
withMetadata
-
withMetadata
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 keyvalue- the metadata value- Returns:
- a new
Eventincluding the given entry - Throws:
IllegalArgumentException- ifkeyorvalueisnull
-
equals
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 withObjects::equals(Object,Object). -
hashCode
-
toString
-
type
-
tags
-
data
-
id
-
metadata
-