Package org.jmolecules.ddd.types
Interface Association<T extends AggregateRoot<T,ID>,ID extends Identifier>
-
- All Superinterfaces:
Identifiable<ID>
- All Known Implementing Classes:
SimpleAssociation
public interface Association<T extends AggregateRoot<T,ID>,ID extends Identifier> extends Identifiable<ID>
An association to anAggregateRoot
.- See Also:
-
-
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description static <T extends AggregateRoot<T,ID>,ID extends Identifier>
Association<T,ID>forAggregate(T aggregate)
static <T extends AggregateRoot<T,ID>,ID extends Identifier>
Association<T,ID>forId(ID identifier)
Creates anAssociation
pointing to the givenIdentifier
.default boolean
pointsTo(ID identifier)
default boolean
pointsTo(T aggregate)
Returns whether the currentAssociation
points to the givenAggregateRoot
.default boolean
pointsToSameAggregateAs(Association<?,ID> other)
Returns whether the currentAssociation
points to the sameAggregateRoot
as the given one.-
Methods inherited from interface org.jmolecules.ddd.types.Identifiable
getId
-
-
-
-
-
Method Detail
-
forAggregate
static <T extends AggregateRoot<T,ID>,ID extends Identifier> Association<T,ID> forAggregate(T aggregate)
- Type Parameters:
T
- the concreteAggregateRoot
type.ID
- the concreteIdentifier
type.- Parameters:
aggregate
- must not be null.- Returns:
- an
Association
pointing to theIdentifier
of the givenAggregateRoot
, will never be null. - Since:
- 1.2
-
forId
static <T extends AggregateRoot<T,ID>,ID extends Identifier> Association<T,ID> forId(ID identifier)
Creates anAssociation
pointing to the givenIdentifier
.- Type Parameters:
T
- the concreteAggregateRoot
type.ID
- the concreteIdentifier
type.- Parameters:
identifier
- must not be null.- Returns:
- an
Association
pointing to the givenIdentifier
, will never be null. - Since:
- 1.2
-
pointsToSameAggregateAs
default boolean pointsToSameAggregateAs(Association<?,ID> other)
Returns whether the currentAssociation
points to the sameAggregateRoot
as the given one. Unlike#equals(Object)
and#hashCode()
that also check for type equality of theAssociation
itself, this only compares the targetIdentifier
instances.- Parameters:
other
- must not be null.- Returns:
- whether the current
Association
points to the sameAggregateRoot
as the given one. - Since:
- 1.2
-
pointsTo
default boolean pointsTo(ID identifier)
Returns whether the currentAssociation
points to theAggregateRoot
with the givenIdentifier
. Unlike#equals(Object)
and#hashCode()
that also check for type equality of theAssociation
itself, this only compares the targetIdentifier
instances.- Parameters:
identifier
-- Returns:
- whether the current
Association
points to theAggregateRoot
with the givenIdentifier
. - Since:
- 1.4
-
pointsTo
default boolean pointsTo(T aggregate)
Returns whether the currentAssociation
points to the givenAggregateRoot
. Unlike#equals(Object)
and#hashCode()
that also check for type equality of theAssociation
itself, this only compares the targetIdentifier
instances.- Parameters:
aggregate
- must not be null.- Returns:
- whether the current
Association
points to the givenAggregateRoot
. - Since:
- 1.4
-
-