-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Static factory methods for Association #48
Conversation
Thinking about this, I wonder how we should treat equality for SomeIdentifier identifier = new SomeIdentifier(…);
SomeAggregate aggregate = new SomeAggregate(identifier);
assertThat(Associations.forId(identifier)).isEqualTo(Association.forAggregate(aggregate)); While they're logically the same as they're pointing to the same aggregate for technical reasons, they're currently not as they're implemented using lambdas. that would be resolvable by introducing a dedicated (probably hidden) type. Even with that in place we'd have to answer how that's going to work when comparing those ad hoc class SomeAssociation implements Association<SomeAggregate, SomeIdentifier> { /* … */ }
assertThat(SomeAssociation.of(identifier)).isEqualTo(Association.ofId(identifier)); We're never gonna get this to work symmetrically. I.e. different WDYT? |
Introduced Association.forAggregate(…) and ….forId(…) to easily create Association instances without having to explicitly implement it. Implementations return a SimpleAssociation that implements equals(…) and hashCode() by verifying the equality of both the actual association type and the target identifier. Introduced pointsToSameAggregateAs(…) for identifier only comparison.
fd70b98
to
f8cbe17
Compare
I've updated the feature branch with the package protected |
Introduced Association.forAggregate(…) and ….forId(…) to easily create Association instances without having to explicitly implement it. Implementations return a SimpleAssociation that implements equals(…) and hashCode() by verifying the equality of both the actual association type and the target identifier. Introduced pointsToSameAggregateAs(…) for identifier only comparison.
f8cbe17
to
d9232e3
Compare
Unless there are objections, I'd merge this later tonight or early morning tomorrow. |
Introduced Association.forAggregate(…) and ….forId(…) to easily create Association instances without having to explicitly implement it. Implementations return a SimpleAssociation that implements equals(…) and hashCode() by verifying the equality of both the actual association type and the target identifier. Introduced pointsToSameAggregateAs(…) for identifier only comparison.
That's merged. |
Following xmolecules/jmolecules#48 for proper equals(…)/hashCode() handling of the Association instances returned.
Introduced
Association.forAggregate(…)
and….forId(…)
to easily createAssociation
instances without having to explicitly implement it.