use of org.qi4j.api.association.ManyAssociationWrapper in project qi4j-sdk by Qi4j.
the class ManyAssociationInstance method equals.
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ManyAssociation<?> that = (ManyAssociation) o;
// Unwrap if needed
while (that instanceof ManyAssociationWrapper) {
that = ((ManyAssociationWrapper) that).next();
}
// Descriptor equality
ManyAssociationInstance<?> thatInstance = (ManyAssociationInstance) that;
AssociationDescriptor thatDescriptor = (AssociationDescriptor) thatInstance.associationInfo();
if (!associationInfo.equals(thatDescriptor)) {
return false;
}
// State equality
if (manyAssociationState.count() != thatInstance.manyAssociationState.count()) {
return false;
}
for (EntityReference ref : manyAssociationState) {
if (!thatInstance.manyAssociationState.contains(ref)) {
return false;
}
}
return true;
}
Aggregations