Class AbstractDomainEvent.Builder<ID extends EntityId,​TYPE extends AbstractDomainEvent<ID>,​BUILDER extends AbstractDomainEvent.Builder<ID,​TYPE,​BUILDER>>

  • Type Parameters:
    ID - Type of the entity identifier.
    TYPE - Type of the event.
    BUILDER - Type of the builder.
    Enclosing class:
    AbstractDomainEvent<ID extends EntityId>

    protected abstract static class AbstractDomainEvent.Builder<ID extends EntityId,​TYPE extends AbstractDomainEvent<ID>,​BUILDER extends AbstractDomainEvent.Builder<ID,​TYPE,​BUILDER>>
    extends AbstractEvent.Builder<TYPE,​BUILDER>
    Base class for event builders.
    • Constructor Detail

      • Builder

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

      • entityIdPath

        public final BUILDER entityIdPath​(@NotNull
                                          @NotNull EntityIdPath entityIdPath)
        Sets the identifier path from aggregate root to the entity that emitted the event.
        Parameters:
        entityIdPath - Path of entity identifiers.
        Returns:
        This builder.
      • entityIdPath

        public final BUILDER entityIdPath​(@NotNull
                                          @NotNull AggregateRootId id)
        Convenience method to set the entity identifier path if the path has only the aggregate root identifer.
        Parameters:
        id - Aggregate root identifier that will be used to create the entity id path.
        Returns:
        This builder.
      • aggregateVersion

        public final BUILDER aggregateVersion​(AggregateVersion aggregateVersion)
        Sets the aggregate version.
        Parameters:
        aggregateVersion - Aggregate version.
        Returns:
        This builder.
      • ensureBuildableAbstractDomainEvent

        protected final void ensureBuildableAbstractDomainEvent()
        Ensures that everything is setup for building the object or throws a runtime exception otherwise.
      • resetAbstractDomainEvent

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