Package org.jmolecules.ddd.types
Class SimpleAssociation<T extends AggregateRoot<T,ID>,ID extends Identifier>
- java.lang.Object
-
- org.jmolecules.ddd.types.SimpleAssociation<T,ID>
-
- All Implemented Interfaces:
Association<T,ID>
,Identifiable<ID>
class SimpleAssociation<T extends AggregateRoot<T,ID>,ID extends Identifier> extends java.lang.Object implements Association<T,ID>
Simple implementation ofAssociation
to effectively only defineequals(Object)
andhashCode()
onAssociation
's static factory methods.- Since:
- 1.2
- See Also:
Association.forId(Identifier)
,Association.forAggregate(AggregateRoot)
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.function.Supplier<ID>
identifier
-
Constructor Summary
Constructors Constructor Description SimpleAssociation(java.util.function.Supplier<ID> identifier)
Creates a newSimpleAssociation
for the given identifier.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
ID
getId()
Returns the identifier.int
hashCode()
java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jmolecules.ddd.types.Association
pointsTo, pointsTo, pointsToSameAggregateAs
-
-
-
-
Field Detail
-
identifier
private final java.util.function.Supplier<ID extends Identifier> identifier
-
-
Constructor Detail
-
SimpleAssociation
SimpleAssociation(java.util.function.Supplier<ID> identifier)
Creates a newSimpleAssociation
for the given identifier.- Parameters:
identifier
- must not be null.
-
-
Method Detail
-
getId
public ID getId()
Description copied from interface:Identifiable
Returns the identifier.- Specified by:
getId
in interfaceIdentifiable<T extends AggregateRoot<T,ID>>
- Returns:
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-