xmolecules / jmolecules

Libraries to help developers express architectural abstractions in Java code
http://jmolecules.org
Apache License 2.0
1.26k stars 104 forks source link

Bound of `T` for `ddd.types.Entity<T, ID>` is wrong? #92

Closed larsw closed 1 year ago

larsw commented 1 year ago

The current interface states

public interface Entity<T extends AggregateRoot<T, ?>, ID> extends Identifiable<ID> {}

Is this a cut'n'paste error? Shouldn't the bound of T be Entity<T, ID?

odrotbohm commented 1 year ago

No. As described here (the section starting with "There's still one question that we haven't answered yet…"), an entity defines which aggregate it belongs to, as it can only be owned by one aggregate. This allows to detect that an entity is referred to from an aggregate it doesn't belong (the OrderItem in the Customer type in the example).