use of org.apache.commons.lang.builder.EqualsBuilder in project candlepin by candlepin.
the class Product method equals.
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
boolean equals = false;
if (obj instanceof Product) {
Product that = (Product) obj;
// TODO:
// Maybe it would be better to check the UUID field and only check the following if
// both products have null UUIDs? By not doing this check, we run the risk of two
// different products being considered equal if they happen to have the same values at
// the time they're checked, or two products not being considered equal if they
// represent the same product in different states.
equals = new EqualsBuilder().append(this.id, that.id).append(this.name, that.name).append(this.multiplier, that.multiplier).append(this.locked, that.locked).append(this.attributes, that.attributes).isEquals();
// Check our collections.
// Impl note: We can't use .equals here on the collections, as Hibernate's special
// collections explicitly state that they break the contract on .equals. As such, we
// have to step through each collection and do a manual comparison. Ugh.
equals = equals && Util.collectionsAreEqual(this.dependentProductIds, that.dependentProductIds);
// Compare content UUIDs
equals = equals && Util.collectionsAreEqual(this.productContent, that.productContent, new Comparator<ProductContent>() {
public int compare(ProductContent pc1, ProductContent pc2) {
// objects, but we'll verify that just in case they do.
return pc1 == pc2 || (pc1 != null && pc1.equals(pc2)) ? 0 : 1;
}
});
}
return equals;
}
use of org.apache.commons.lang.builder.EqualsBuilder in project candlepin by candlepin.
the class ProductContentData method equals.
@Override
public boolean equals(Object obj) {
if (obj == null || !(obj instanceof ProductContentData)) {
return false;
}
if (obj == this) {
return true;
}
ProductContentData that = (ProductContentData) obj;
EqualsBuilder builder = new EqualsBuilder().append(this.content, that.content).append(this.enabled, that.enabled);
return builder.isEquals();
}
use of org.apache.commons.lang.builder.EqualsBuilder in project candlepin by candlepin.
the class ProductContent method equals.
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof ProductContent) {
ProductContent that = (ProductContent) obj;
// We're only interested in ensuring the mapping between the two objects is the same.
String thisContentUuid = this.getContent() != null ? this.getContent().getUuid() : null;
String thatContentUuid = that.getContent() != null ? that.getContent().getUuid() : null;
return new EqualsBuilder().append(thisContentUuid, thatContentUuid).append(this.isEnabled(), that.isEnabled()).isEquals();
}
return false;
}
use of org.apache.commons.lang.builder.EqualsBuilder in project candlepin by candlepin.
the class PoolDTO method equals.
/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof PoolDTO && super.equals(obj)) {
PoolDTO that = (PoolDTO) obj;
// We are not interested in making sure nested objects are equal; we're only
// concerned with the reference to such an object.
String thisOwnerId = this.getOwner() != null ? this.getOwner().getId() : null;
String thatOwnerId = that.getOwner() != null ? that.getOwner().getId() : null;
String thisSourceEntitlementId = this.getSourceEntitlement() != null ? this.getSourceEntitlement().getId() : null;
String thatSourceEntitlementId = that.getSourceEntitlement() != null ? that.getSourceEntitlement().getId() : null;
String thisCertificateId = this.getCertificate() != null ? this.getCertificate().getId() : null;
String thatCertificateId = that.getCertificate() != null ? that.getCertificate().getId() : null;
EqualsBuilder builder = new EqualsBuilder().append(this.getId(), that.getId()).append(this.getType(), that.getType()).append(thisOwnerId, thatOwnerId).append(this.isActiveSubscription(), that.isActiveSubscription()).append(this.isCreatedByShare(), that.isCreatedByShare()).append(this.hasSharedAncestor(), that.hasSharedAncestor()).append(thisSourceEntitlementId, thatSourceEntitlementId).append(this.getQuantity(), that.getQuantity()).append(this.getStartDate(), that.getStartDate()).append(this.getEndDate(), that.getEndDate()).append(this.getAttributes(), that.getAttributes()).append(this.getRestrictedToUsername(), that.getRestrictedToUsername()).append(this.getContractNumber(), that.getContractNumber()).append(this.getAccountNumber(), that.getAccountNumber()).append(this.getOrderNumber(), that.getOrderNumber()).append(this.getConsumed(), that.getConsumed()).append(this.getExported(), that.getExported()).append(this.getShared(), that.getShared()).append(this.getBranding(), that.getBranding()).append(this.getCalculatedAttributes(), that.getCalculatedAttributes()).append(this.getUpstreamPoolId(), that.getUpstreamPoolId()).append(this.getUpstreamEntitlementId(), that.getUpstreamEntitlementId()).append(this.getUpstreamConsumerId(), that.getUpstreamConsumerId()).append(this.getProductName(), that.getProductName()).append(this.getProductId(), that.getProductId()).append(this.getProductAttributes(), that.getProductAttributes()).append(this.getStackId(), that.getStackId()).append(this.isStacked(), that.isStacked()).append(this.isDevelopmentPool(), that.isDevelopmentPool()).append(this.getDerivedProductAttributes(), that.getDerivedProductAttributes()).append(this.getDerivedProductId(), that.getDerivedProductId()).append(this.getDerivedProductName(), that.getDerivedProductName()).append(this.getProvidedProducts(), that.getProvidedProducts()).append(this.getDerivedProvidedProducts(), that.getDerivedProvidedProducts()).append(this.getSourceStackId(), that.getSourceStackId()).append(this.getSubscriptionSubKey(), that.getSubscriptionSubKey()).append(this.getSubscriptionId(), that.getSubscriptionId()).append(thisCertificateId, thatCertificateId);
return builder.isEquals();
}
return false;
}
use of org.apache.commons.lang.builder.EqualsBuilder in project candlepin by candlepin.
the class ProductDTO method equals.
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof ProductDTO && super.equals(obj)) {
ProductDTO that = (ProductDTO) obj;
EqualsBuilder builder = new EqualsBuilder().append(this.getUuid(), that.getUuid()).append(this.getMultiplier(), that.getMultiplier()).append(this.getId(), that.getId()).append(this.getName(), that.getName()).append(this.getAttributes(), that.getAttributes()).append(this.getDependentProductIds(), that.getDependentProductIds());
// As with many collections here, we need to explicitly check the elements ourselves,
// since it seems very common for collection implementations to not properly implement
// .equals
// Note that we're using the boolean operator here as a shorthand way to skip checks
// when the equality check has already failed.
boolean equals = builder.isEquals();
// Check product content
equals = equals && Util.collectionsAreEqual(this.getProductContent(), that.getProductContent());
return equals;
}
return false;
}
Aggregations