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 Details

    • Builder

      public Builder(TYPE delegate)
      Constructor with event.
      Parameters:
      delegate - Event to populate with data.
  • Method Details

    • eventId

      public final BUILDER eventId(@NotNull @NotNull EventId eventId)
      Sets the unique identifier of the event.
      Parameters:
      eventId - Unique event id.
      Returns:
      This builder.
    • timestamp

      public final BUILDER timestamp(@NotNull @NotNull ZonedDateTime eventTimestamp)
      Sets the date/Time the event was created.
      Parameters:
      eventTimestamp - Date/Time the event was created.
      Returns:
      This builder.
    • correlationId

      public final BUILDER correlationId(EventId correlationId)
      Sets the event this one correlates to.
      Parameters:
      correlationId - Identifier of the event this one correlates to.
      Returns:
      This builder.
    • causationId

      public final BUILDER causationId(EventId causationId)
      Sets the event that caused this one.
      Parameters:
      causationId - Identifier of the event that caused this one.
      Returns:
      This builder.
    • causingEvent

      public final BUILDER causingEvent(Event event)
      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

      protected final void resetAbstractEvent(TYPE delegate)
      Sets the internal instance to a new one. This must be called within the build method.
      Parameters:
      delegate - Delegate to use.
    • delegate

      protected final TYPE delegate()
      Returns the delegate.
      Returns:
      Delegate.
    • ensureNotNull

      protected final void ensureNotNull(String name, Object value)
      Ensures that a filed is set or throws a runtime exception otherwise.
      Parameters:
      name - Name of the field.
      value - Value to test for null.