java.lang.Object
net.pincette.jes.Event
Utilities to work with events.
- Since:
- 3.0
- Author:
- Werner Donné
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanadded(JsonObject event, String jsonPointer) Returnstrueif the field atjsonPointerwas added.static JsonObjectapplyEvent(JsonObject aggregate, JsonObject event) Applies an event to an aggregate instance, which results in the next version of the aggregate.static booleanchanged(JsonObject event, String jsonPointer) Returnstrueif the field atjsonPointerhas changed.static booleanchanged(JsonObject event, String jsonPointer, JsonValue from, JsonValue to) Returnstrueif the field atjsonPointerhas changed from the value infromto the value into.static booleanisEvent(JsonObject event) Checks ifeventhas the proper event structure.static booleanisNext(JsonObject aggregate, JsonObject event) Checks if the event has the next sequence number for the aggregate.static booleanremoved(JsonObject event, String jsonPointer) Returnstrueif the field atjsonPointerwas removed.static StringsequenceErrorMessage(JsonObject aggregate, JsonObject event) Creates a standard message to alert event sequence errors.
-
Method Details
-
added
Returnstrueif the field atjsonPointerwas added. It examines the_opsfield for this.- Parameters:
event- the full event, which has the_beforefield.jsonPointer- the path into the aggregate.- Returns:
truewhen the event expresses the addition of the given field.- Since:
- 1.4.1
-
applyEvent
Applies an event to an aggregate instance, which results in the next version of the aggregate.- Parameters:
aggregate- the given aggregate instance.event- the given event.- Returns:
- The next version of the aggregate instance.
- Since:
- 1.2
-
changed
Returnstrueif the field atjsonPointerhas changed. It examines the_opsfield for this.- Parameters:
event- the event.jsonPointer- the path into the aggregate.- Returns:
truewhen the event expresses a change of the given field.- Since:
- 1.0
-
changed
Returnstrueif the field atjsonPointerhas changed from the value infromto the value into. It examines the_opsfield for this.- Parameters:
event- the full event, which has the_beforefield.jsonPointer- the path into the aggregate.from- the original value.to- the new value.- Returns:
truewhen the event expresses a change of the given field.- Since:
- 1.0
-
isEvent
Checks ifeventhas the proper event structure. This means it should be a managed object with an_opsfield.- Parameters:
event- the given event.- Returns:
- The check report.
- Since:
- 1.0
- See Also:
-
isNext
Checks if the event has the next sequence number for the aggregate. Event log replicators can use this to detect corruption.- Parameters:
aggregate- the aggregate instance.event- the event.- Returns:
trueif the event is the next one,falseotherwise.- Since:
- 1.0
-
removed
Returnstrueif the field atjsonPointerwas removed. It examines the_opsfield for this.- Parameters:
event- the event.jsonPointer- the path into the aggregate.- Returns:
truewhen the event expresses the removal of the given field.- Since:
- 1.4.1
-
sequenceErrorMessage
Creates a standard message to alert event sequence errors. Events are numbered with the_seqfield. When an event listener detect a "hole" in the numbering it can use this message to log the corruption.- Parameters:
aggregate- the aggregate about which the error message is produced.event- the event about which the error message is produced.- Returns:
- The generated error message.
- Since:
- 1.0
-