Module org.fuin.ddd4j
Package org.fuin.ddd4j.ddd
Class AbstractEvent.Builder<TYPE extends AbstractEvent,BUILDER extends AbstractEvent.Builder<TYPE,BUILDER>>
java.lang.Object
org.fuin.ddd4j.ddd.AbstractEvent.Builder<TYPE,BUILDER>
- Type Parameters:
TYPE- Type of the event.BUILDER- Type of the builder.
- Direct Known Subclasses:
AbstractDomainEvent.Builder
- Enclosing class:
- AbstractEvent
protected abstract static class AbstractEvent.Builder<TYPE extends AbstractEvent,BUILDER extends AbstractEvent.Builder<TYPE,BUILDER>>
extends Object
Base class for event builders.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal BUILDERcausationId(EventId causationId) Sets the event that caused this one.final BUILDERcausingEvent(Event event) Takes the id of the event as causation id and copies the correlation id.final BUILDERcorrelationId(EventId correlationId) Sets the event this one correlates to.protected final TYPEdelegate()Returns the delegate.protected final voidEnsures that everything is setup for building the object or throws a runtime exception otherwise.protected final voidensureNotNull(String name, Object value) Ensures that a filed is set or throws a runtime exception otherwise.final BUILDERSets the unique identifier of the event.protected final voidresetAbstractEvent(TYPE delegate) Sets the internal instance to a new one.final BUILDERtimestamp(@NotNull ZonedDateTime eventTimestamp) Sets the date/Time the event was created.
-
Constructor Details
-
Builder
Constructor with event.- Parameters:
delegate- Event to populate with data.
-
-
Method Details
-
eventId
Sets the unique identifier of the event.- Parameters:
eventId- Unique event id.- Returns:
- This builder.
-
timestamp
Sets the date/Time the event was created.- Parameters:
eventTimestamp- Date/Time the event was created.- Returns:
- This builder.
-
correlationId
Sets the event this one correlates to.- Parameters:
correlationId- Identifier of the event this one correlates to.- Returns:
- This builder.
-
causationId
Sets the event that caused this one.- Parameters:
causationId- Identifier of the event that caused this one.- Returns:
- This builder.
-
causingEvent
Takes the id of the event as causation id and copies the correlation id.- Parameters:
event- Event that caused the one that is being build.- Returns:
- This builder.
-
ensureBuildableAbstractEvent
protected final void ensureBuildableAbstractEvent()Ensures that everything is setup for building the object or throws a runtime exception otherwise. -
resetAbstractEvent
Sets the internal instance to a new one. This must be called within the build method.- Parameters:
delegate- Delegate to use.
-
delegate
Returns the delegate.- Returns:
- Delegate.
-
ensureNotNull
Ensures that a filed is set or throws a runtime exception otherwise.- Parameters:
name- Name of the field.value- Value to test for null.
-