Package com.onec.events
Record Class EntityChangedEvent
java.lang.Object
java.lang.Record
com.onec.events.EntityChangedEvent
- Record Components:
changeType- what happened:created,updated,deleted,posted,unposted, orchanged(a coarse "something changed" signal, e.g. register movements after a post).entityType- the kind of entity:catalog,document, orregister.entityName- the entity's registered logical name (e.g.Properties), or*for a non-specific signal.id- the affected row's id, ornullwhen not applicable.naturalKey- the business key that maps the change to an addressable resource — a catalog's code or a document's number (the "slug") — ornullif unknown. Carried so listeners can target a specific resource instead of invalidating everything.
public record EntityChangedEvent(String changeType, String entityType, String entityName, UUID id, String naturalKey)
extends Record
Published whenever a catalog or document changes, regardless of which write path made the change —
the generic REST controllers (raw JDBI) and
repository.save(...) (Spring Data JDBC) both
emit it, so server-side listeners see every change, not just back-office edits (issues
#28, #29).
Consume it with an ordinary Spring @EventListener; the built-in SSE bridge
(browser live updates) is just one such listener. Cache/ISR revalidation, search indexing, and
outbox relays become trivial listeners:
@EventListener
void onChange(EntityChangedEvent event) {
if ("catalog".equals(event.entityType()) && "Properties".equals(event.entityName())) {
revalidate("/properties/" + event.naturalKey()); // slug, not just UUID
}
}
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thechangeTyperecord component.Returns the value of theentityNamerecord component.Returns the value of theentityTyperecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.Returns the value of thenaturalKeyrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
CREATED
- See Also:
-
UPDATED
- See Also:
-
DELETED
- See Also:
-
POSTED
- See Also:
-
UNPOSTED
- See Also:
-
CHANGED
- See Also:
-
CATALOG
- See Also:
-
DOCUMENT
- See Also:
-
REGISTER
- See Also:
-
-
Constructor Details
-
EntityChangedEvent
public EntityChangedEvent(String changeType, String entityType, String entityName, UUID id, String naturalKey) Creates an instance of aEntityChangedEventrecord class.- Parameters:
changeType- the value for thechangeTyperecord componententityType- the value for theentityTyperecord componententityName- the value for theentityNamerecord componentid- the value for theidrecord componentnaturalKey- the value for thenaturalKeyrecord component
-
-
Method Details
-
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. -
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. -
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). -
changeType
Returns the value of thechangeTyperecord component.- Returns:
- the value of the
changeTyperecord component
-
entityType
Returns the value of theentityTyperecord component.- Returns:
- the value of the
entityTyperecord component
-
entityName
Returns the value of theentityNamerecord component.- Returns:
- the value of the
entityNamerecord component
-
id
Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
naturalKey
Returns the value of thenaturalKeyrecord component.- Returns:
- the value of the
naturalKeyrecord component
-