Class AbstractEntity<ROOT_ID extends AggregateRootId,ROOT extends AbstractAggregateRoot<ROOT_ID>,ID extends EntityId>

java.lang.Object
org.fuin.ddd4j.ddd.AbstractEntity<ROOT_ID,ROOT,ID>
Type Parameters:
ROOT - Type of the aggregate root.
ROOT_ID - Type of the aggregate identifier.
ID - Type of the entity identifier.
All Implemented Interfaces:
Entity<ID>

public abstract class AbstractEntity<ROOT_ID extends AggregateRootId,ROOT extends AbstractAggregateRoot<ROOT_ID>,ID extends EntityId> extends Object implements Entity<ID>
Base class for entities.
  • Constructor Details

    • AbstractEntity

      public AbstractEntity(@NotNull ROOT root)
      Constructor with root aggregate.
      Parameters:
      root - Root aggregate.
  • Method Details

    • apply

      protected final void apply(@NotNull @NotNull DomainEvent<?> event)
      Applies the given new event. CAUTION: Don't use this method for applying historic events!
      Parameters:
      event - Event to dispatch to the appropriate event handler method.
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getRoot

      protected final ROOT getRoot()
      Returns the aggregate root the entity belongs to.
      Returns:
      Aggregate root this is a child of.
    • getRootId

      protected final ROOT_ID getRootId()
      Returns the identifier of the aggregate root the entity belongs to.
      Returns:
      Unique aggregate root identifier.