Package org.fuin.ddd4j.ddd
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 Summary
Constructors Constructor Description AbstractEntity(ROOT root)Constructor with root aggregate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidapply(@NotNull DomainEvent<?> event)Applies the given new event.booleanequals(Object obj)protected ROOTgetRoot()Returns the aggregate root the entity belongs to.protected ROOT_IDgetRootId()Returns the identifier of the aggregate root the entity belongs to.inthashCode()
-
-
-
Constructor Detail
-
AbstractEntity
public AbstractEntity(@NotNull ROOT root)Constructor with root aggregate.- Parameters:
root- Root aggregate.
-
-
Method Detail
-
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.
-
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.
-
-