Skip to content

Commit

Permalink
Hacking.
Browse files Browse the repository at this point in the history
  • Loading branch information
odrotbohm committed Aug 25, 2021
1 parent 3774d6c commit 218a259
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
* @see <a href="https://scabl.blogspot.com/2015/04/aeddd-9.html>John Sullivan - Advancing Enterprise DDD - Reinstating
* the Aggregate</a>
*/
public interface AggregateRoot<T extends AggregateRoot<T, ID>, ID extends Identifier> extends Entity<T, ID> {
public interface AggregateRoot<T extends AggregateRoot<T, ID>, ID extends Identifier<T, ID>> extends Entity<T, ID, T> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @see <a href="https://scabl.blogspot.com/2015/04/aeddd-9.html>John Sullivan - Advancing Enterprise DDD - Reinstating
* the Aggregate</a>
*/
public interface Association<T extends AggregateRoot<T, ID>, ID extends Identifier> extends Identifiable<ID> {
public interface Association<T extends AggregateRoot<T, ID>, ID extends Identifier<T, ID>> extends Identifiable<T, ID> {

/**
* Creates an {@link Association} pointing to the {@link Identifier} of the given {@link AggregateRoot}.
Expand All @@ -39,7 +39,7 @@ public interface Association<T extends AggregateRoot<T, ID>, ID extends Identifi
* {@literal null}.
* @since 1.2
*/
static <T extends AggregateRoot<T, ID>, ID extends Identifier> Association<T, ID> forAggregate(T aggregate) {
static <T extends AggregateRoot<T, ID>, ID extends Identifier<T, ID>> Association<T, ID> forAggregate(T aggregate) {

if (aggregate == null) {
throw new IllegalArgumentException("Aggregate must not be null!");
Expand All @@ -57,7 +57,7 @@ static <T extends AggregateRoot<T, ID>, ID extends Identifier> Association<T, ID
* @return an {@link Association} pointing to the given {@link Identifier}, will never be {@literal null}.
* @since 1.2
*/
static <T extends AggregateRoot<T, ID>, ID extends Identifier> Association<T, ID> forId(ID identifier) {
static <T extends AggregateRoot<T, ID>, ID extends Identifier<T, ID>> Association<T, ID> forId(ID identifier) {

if (identifier == null) {
throw new IllegalArgumentException("Identifier must not be null!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@
* @see <a href="https://scabl.blogspot.com/2015/04/aeddd-9.html>John Sullivan - Advancing Enterprise DDD - Reinstating
* the Aggregate</a>
*/
public interface Entity<T extends AggregateRoot<T, ?>, ID> extends Identifiable<ID> {}
public interface Entity<T extends AggregateRoot<T, ?>, ID extends Identifier<S, ID>, S extends Entity<T, ID, S>>
extends Identifiable<S, ID> {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @author Oliver Drotbohm
*/
public interface Identifiable<ID> {
public interface Identifiable<T extends Identifiable<T, ID>, ID extends Identifier<T, ID>> {

/**
* Returns the identifier.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
* @author Oliver Drotbohm
* @see Identifiable
*/
public interface Identifier {
public interface Identifier<T extends Identifiable<T, ID>, ID extends Identifier<T, ID>> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
* Reference (Evans) - Repositories</a>
* @since 1.2
*/
public interface Repository<T extends AggregateRoot<T, ID>, ID extends Identifier> {}
public interface Repository<T extends AggregateRoot<T, ID>, ID extends Identifier<T, ID>> {}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* @see Association#forId(Identifier)
* @see Association#forAggregate(AggregateRoot)
*/
class SimpleAssociation<T extends AggregateRoot<T, ID>, ID extends Identifier> implements Association<T, ID> {
class SimpleAssociation<T extends AggregateRoot<T, ID>, ID extends Identifier<T, ID>> implements Association<T, ID> {

private final Supplier<ID> identifier;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void rejectsNullReferenceAggregate() {
.isThrownBy(() -> Association.forId(new SampleIdentifier()).pointsToSameAggregateAs(null));
}

static class SampleIdentifier implements Identifier {}
static class SampleIdentifier implements Identifier<SampleAggregate, SampleIdentifier> {}

static class SampleAggregate implements AggregateRoot<SampleAggregate, SampleIdentifier> {

Expand Down

0 comments on commit 218a259

Please sign in to comment.