Search in sources :

Example 1 with AssociationWrapper

use of org.qi4j.api.association.AssociationWrapper in project qi4j-sdk by Qi4j.

the class AssociationInstance method equals.

@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }
    if (o == null || getClass() != o.getClass()) {
        return false;
    }
    Association<?> that = (Association) o;
    // Unwrap if needed
    while (that instanceof AssociationWrapper) {
        that = ((AssociationWrapper) that).next();
    }
    // Descriptor equality
    AssociationInstance<?> thatInstance = (AssociationInstance) that;
    AssociationDescriptor thatDescriptor = (AssociationDescriptor) thatInstance.associationInfo();
    if (!associationInfo.equals(thatDescriptor)) {
        return false;
    }
    // State equality
    if (associationState.get() != null ? !associationState.get().equals(thatInstance.associationState.get()) : thatInstance.associationState.get() != null) {
        return false;
    }
    return true;
}
Also used : Association(org.qi4j.api.association.Association) AssociationWrapper(org.qi4j.api.association.AssociationWrapper) AssociationDescriptor(org.qi4j.api.association.AssociationDescriptor)

Aggregations

Association (org.qi4j.api.association.Association)1 AssociationDescriptor (org.qi4j.api.association.AssociationDescriptor)1 AssociationWrapper (org.qi4j.api.association.AssociationWrapper)1