Module org.fuin.ddd4j
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 -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidapply(@NotNull DomainEvent<?> event) Applies the given new event.final booleanprotected final ROOTgetRoot()Returns the aggregate root the entity belongs to.protected final ROOT_IDReturns the identifier of the aggregate root the entity belongs to.final inthashCode()
-
Constructor Details
-
AbstractEntity
Constructor with root aggregate.- Parameters:
root- Root aggregate.
-
-
Method Details
-
apply
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() -
equals
-
getRoot
Returns the aggregate root the entity belongs to.- Returns:
- Aggregate root this is a child of.
-
getRootId
Returns the identifier of the aggregate root the entity belongs to.- Returns:
- Unique aggregate root identifier.
-