Repository: incubator-atlas Updated Branches: refs/heads/master ed4ae0e3e -> 3bffc0dcc
Update hashCode and equals method to use standard JDK libraries Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/3bffc0dc Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/3bffc0dc Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/3bffc0dc Branch: refs/heads/master Commit: 3bffc0dcc525d456d84011170ffe9f62885cb6c8 Parents: ed4ae0e Author: apoorvnaik <[email protected]> Authored: Tue Dec 13 14:33:18 2016 +0530 Committer: Vimal Sharma <[email protected]> Committed: Tue Dec 13 14:33:18 2016 +0530 ---------------------------------------------------------------------- .../org/apache/atlas/catalog/BaseRequest.java | 18 ++--- .../java/org/apache/atlas/EntityAuditEvent.java | 32 ++++----- .../org/apache/atlas/ha/HAConfiguration.java | 47 +++---------- .../atlas/model/instance/AtlasEntity.java | 56 ++++++--------- .../atlas/model/instance/AtlasEntityHeader.java | 24 +++---- .../instance/AtlasEntityWithAssociations.java | 23 +++---- .../atlas/model/instance/AtlasObjectId.java | 17 ++--- .../atlas/model/instance/AtlasStruct.java | 17 ++--- .../model/instance/EntityMutationResponse.java | 18 ++--- .../atlas/model/instance/EntityMutations.java | 31 +++------ .../atlas/model/lineage/AtlasLineageInfo.java | 32 +++------ .../atlas/model/typedef/AtlasBaseTypeDef.java | 51 +++++++------- .../model/typedef/AtlasClassificationDef.java | 34 ++++----- .../atlas/model/typedef/AtlasEntityDef.java | 34 ++++----- .../atlas/model/typedef/AtlasEnumDef.java | 38 ++++------- .../atlas/model/typedef/AtlasStructDef.java | 72 ++++++-------------- .../atlas/model/typedef/AtlasTypeDefHeader.java | 21 +++--- .../entity/EntityNotificationImpl.java | 21 ++---- .../AbstractNotificationConsumerTest.java | 18 ++--- release-log.txt | 1 + .../atlas/repository/graph/GraphHelper.java | 41 +++-------- .../apache/atlas/typesystem/Referenceable.java | 16 +++++ .../apache/atlas/typesystem/persistence/Id.java | 31 +++------ .../typesystem/types/AttributeDefinition.java | 52 ++++---------- .../atlas/typesystem/types/AttributeInfo.java | 47 ++++--------- .../typesystem/types/EnumTypeDefinition.java | 27 +++----- .../types/HierarchicalTypeDefinition.java | 37 +++------- .../atlas/typesystem/types/Multiplicity.java | 31 +++------ .../typesystem/types/StructTypeDefinition.java | 27 +++----- .../apache/atlas/web/params/AbstractParam.java | 17 ++--- 30 files changed, 319 insertions(+), 612 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/catalog/src/main/java/org/apache/atlas/catalog/BaseRequest.java ---------------------------------------------------------------------- diff --git a/catalog/src/main/java/org/apache/atlas/catalog/BaseRequest.java b/catalog/src/main/java/org/apache/atlas/catalog/BaseRequest.java index b0e428f..c03d6d0 100644 --- a/catalog/src/main/java/org/apache/atlas/catalog/BaseRequest.java +++ b/catalog/src/main/java/org/apache/atlas/catalog/BaseRequest.java @@ -22,6 +22,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.Objects; /** * Base user API request. @@ -75,25 +76,20 @@ public abstract class BaseRequest implements Request { return additionalSelectProperties; } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - BaseRequest that = (BaseRequest) o; - - return queryProperties.equals(that.queryProperties) && - updateProperties.equals(that.updateProperties) && - additionalSelectProperties.equals(that.additionalSelectProperties) && - queryString == null ? that.queryString == null : queryString.equals(that.queryString); + return Objects.equals(queryProperties, that.queryProperties) && + Objects.equals(updateProperties, that.updateProperties) && + Objects.equals(queryString, that.queryString) && + Objects.equals(additionalSelectProperties, that.additionalSelectProperties); } @Override public int hashCode() { - int result = queryProperties.hashCode(); - result = 31 * result + updateProperties.hashCode(); - result = 31 * result + (queryString != null ? queryString.hashCode() : 0); - result = 31 * result + additionalSelectProperties.hashCode(); - return result; + return Objects.hash(queryProperties, updateProperties, queryString, additionalSelectProperties); } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/client/src/main/java/org/apache/atlas/EntityAuditEvent.java ---------------------------------------------------------------------- diff --git a/client/src/main/java/org/apache/atlas/EntityAuditEvent.java b/client/src/main/java/org/apache/atlas/EntityAuditEvent.java index 29a04ab..7eaa556 100644 --- a/client/src/main/java/org/apache/atlas/EntityAuditEvent.java +++ b/client/src/main/java/org/apache/atlas/EntityAuditEvent.java @@ -22,6 +22,8 @@ import org.apache.atlas.typesystem.IReferenceableInstance; import org.apache.atlas.typesystem.json.InstanceSerialization; import org.apache.commons.lang.StringUtils; +import java.util.Objects; + /** * Structure of entity audit event */ @@ -52,28 +54,22 @@ public class EntityAuditEvent { } @Override - public boolean equals(Object other) { - if (this == other) { - return true; - } - - if (!(other instanceof EntityAuditEvent)) { - return false; - } - - EntityAuditEvent otherEvent = (EntityAuditEvent) other; - return StringUtils.equals(entityId, otherEvent.entityId) && - (timestamp == otherEvent.timestamp) && - StringUtils.equals(user, otherEvent.user) && - (action == otherEvent.action) && - StringUtils.equals(details, otherEvent.details) && - StringUtils.equals(eventKey, otherEvent.eventKey) && - StringUtils.equals(getEntityDefinitionString(), otherEvent.getEntityDefinitionString()); + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + EntityAuditEvent that = (EntityAuditEvent) o; + return timestamp == that.timestamp && + Objects.equals(entityId, that.entityId) && + Objects.equals(user, that.user) && + action == that.action && + Objects.equals(details, that.details) && + Objects.equals(eventKey, that.eventKey) && + Objects.equals(entityDefinition, that.entityDefinition); } @Override public int hashCode() { - return toString().hashCode(); + return Objects.hash(entityId, timestamp, user, action, details, eventKey, entityDefinition); } @Override http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/common/src/main/java/org/apache/atlas/ha/HAConfiguration.java ---------------------------------------------------------------------- diff --git a/common/src/main/java/org/apache/atlas/ha/HAConfiguration.java b/common/src/main/java/org/apache/atlas/ha/HAConfiguration.java index aefaef5..7cfd553 100644 --- a/common/src/main/java/org/apache/atlas/ha/HAConfiguration.java +++ b/common/src/main/java/org/apache/atlas/ha/HAConfiguration.java @@ -23,6 +23,7 @@ import org.apache.commons.configuration.Configuration; import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * A wrapper for getting configuration entries related to HighAvailability. @@ -151,47 +152,21 @@ public final class HAConfiguration { @Override public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; ZookeeperProperties that = (ZookeeperProperties) o; - - if (retriesSleepTimeMillis != that.retriesSleepTimeMillis) { - return false; - } - if (numRetries != that.numRetries) { - return false; - } - if (sessionTimeout != that.sessionTimeout) { - return false; - } - if (!connectString.equals(that.connectString)) { - return false; - } - if (!zkRoot.equals(that.zkRoot)) { - return false; - } - if (acl != null ? !acl.equals(that.acl) : that.acl != null) { - return false; - } - return !(auth != null ? !auth.equals(that.auth) : that.auth != null); - + return retriesSleepTimeMillis == that.retriesSleepTimeMillis && + numRetries == that.numRetries && + sessionTimeout == that.sessionTimeout && + Objects.equals(connectString, that.connectString) && + Objects.equals(zkRoot, that.zkRoot) && + Objects.equals(acl, that.acl) && + Objects.equals(auth, that.auth); } @Override public int hashCode() { - int result = connectString.hashCode(); - result = 31 * result + zkRoot.hashCode(); - result = 31 * result + retriesSleepTimeMillis; - result = 31 * result + numRetries; - result = 31 * result + sessionTimeout; - result = 31 * result + (acl != null ? acl.hashCode() : 0); - result = 31 * result + (auth != null ? auth.hashCode() : 0); - return result; + return Objects.hash(connectString, zkRoot, retriesSleepTimeMillis, numRetries, sessionTimeout, acl, auth); } public boolean hasAcl() { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntity.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntity.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntity.java index 5288cbf..4e4a9e8 100644 --- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntity.java +++ b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntity.java @@ -17,28 +17,28 @@ */ package org.apache.atlas.model.instance; +import org.apache.atlas.model.PList; +import org.apache.atlas.model.SearchFilter.SortType; +import org.apache.atlas.model.typedef.AtlasEntityDef; +import org.codehaus.jackson.annotate.JsonAutoDetect; +import org.codehaus.jackson.annotate.JsonIgnore; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.codehaus.jackson.map.annotate.JsonSerialize; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSeeAlso; import java.io.Serializable; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.UUID; import java.util.concurrent.atomic.AtomicLong; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlSeeAlso; - -import org.apache.atlas.model.PList; -import org.apache.atlas.model.SearchFilter.SortType; -import org.apache.atlas.model.typedef.AtlasEntityDef; -import org.codehaus.jackson.annotate.JsonAutoDetect; -import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE; - -import org.codehaus.jackson.annotate.JsonIgnore; -import org.codehaus.jackson.annotate.JsonIgnoreProperties; -import org.codehaus.jackson.map.annotate.JsonSerialize; +import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY; /** @@ -190,30 +190,18 @@ public class AtlasEntity extends AtlasStruct implements Serializable { if (!super.equals(o)) { return false; } AtlasEntity that = (AtlasEntity) o; - - if (guid != null ? !guid.equals(that.guid) : that.guid != null) { return false; } - if (status != null ? !status.equals(that.status) : that.status != null) { return false; } - if (createdBy != null ? !createdBy.equals(that.createdBy) : that.createdBy != null) { return false; } - if (updatedBy != null ? !updatedBy.equals(that.updatedBy) : that.updatedBy != null) { return false; } - if (createTime != null ? !createTime.equals(that.createTime) : that.createTime != null) { return false; } - if (updateTime != null ? !updateTime.equals(that.updateTime) : that.updateTime != null) { return false; } - if (version != null ? !version.equals(that.version) : that.version != null) { return false; } - - return true; + return Objects.equals(guid, that.guid) && + status == that.status && + Objects.equals(createdBy, that.createdBy) && + Objects.equals(updatedBy, that.updatedBy) && + Objects.equals(createTime, that.createTime) && + Objects.equals(updateTime, that.updateTime) && + Objects.equals(version, that.version); } @Override public int hashCode() { - int result = super.hashCode(); - - result = 31 * result + (guid != null ? guid.hashCode() : 0); - result = 31 * result + (status != null ? status.hashCode() : 0); - result = 31 * result + (createdBy != null ? createdBy.hashCode() : 0); - result = 31 * result + (updatedBy != null ? updatedBy.hashCode() : 0); - result = 31 * result + (createTime != null ? createTime.hashCode() : 0); - result = 31 * result + (updateTime != null ? updateTime.hashCode() : 0); - result = 31 * result + (version != null ? version.hashCode() : 0); - return result; + return Objects.hash(super.hashCode(), guid, status, createdBy, updatedBy, createTime, updateTime, version); } @Override http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeader.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeader.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeader.java index d9c74ae..0c4de4d 100644 --- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeader.java +++ b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityHeader.java @@ -21,6 +21,7 @@ import java.io.Serializable; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.Objects; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -123,27 +124,18 @@ public class AtlasEntityHeader extends AtlasStruct implements Serializable { @Override public boolean equals(Object o) { - if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { return false; } - if (!super.equals(o)) { return false; } - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; AtlasEntityHeader that = (AtlasEntityHeader) o; - - if (guid != null ? !guid.equals(that.guid) : that.guid != null) { return false; } - if (status != null ? !status.equals(that.status) : that.status != null) { return false; } - if (displayText != null ? !displayText.equals(that.displayText) : that.displayText != null) { return false; } - - return true; + return Objects.equals(guid, that.guid) && + status == that.status && + Objects.equals(displayText, that.displayText); } @Override public int hashCode() { - int result = super.hashCode(); - - result = 31 * result + (guid != null ? guid.hashCode() : 0); - result = 31 * result + (status != null ? status.hashCode() : 0); - result = 31 * result + (displayText != null ? displayText.hashCode() : 0); - return result; + return Objects.hash(super.hashCode(), guid, status, displayText); } @Override http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityWithAssociations.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityWithAssociations.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityWithAssociations.java index 4ddd585..146d3c9 100644 --- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityWithAssociations.java +++ b/intg/src/main/java/org/apache/atlas/model/instance/AtlasEntityWithAssociations.java @@ -32,6 +32,7 @@ import java.io.Serializable; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.Objects; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY; @@ -90,15 +91,16 @@ public class AtlasEntityWithAssociations extends AtlasEntity implements Serializ @Override public boolean equals(Object o) { - if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { return false; } - if (!super.equals(o)) { return false; } - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; AtlasEntityWithAssociations that = (AtlasEntityWithAssociations) o; + return Objects.equals(classifications, that.classifications); + } - if (classifications != null ? !classifications.equals(that.classifications) : that.classifications != null) { return false; } - - return true; + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), classifications); } public List<AtlasClassification> getClassifications() { @@ -110,13 +112,6 @@ public class AtlasEntityWithAssociations extends AtlasEntity implements Serializ } @Override - public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (classifications != null ? classifications.hashCode() : 0); - return result; - } - - @Override public String toString() { return toString(new StringBuilder()).toString(); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/intg/src/main/java/org/apache/atlas/model/instance/AtlasObjectId.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasObjectId.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasObjectId.java index bedd4d9..4896e9d 100644 --- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasObjectId.java +++ b/intg/src/main/java/org/apache/atlas/model/instance/AtlasObjectId.java @@ -20,6 +20,7 @@ package org.apache.atlas.model.instance; import java.io.Serializable; import java.util.List; import java.util.Map; +import java.util.Objects; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -118,22 +119,16 @@ public class AtlasObjectId implements Serializable { @Override public boolean equals(Object o) { - if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { return false; } - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; AtlasObjectId that = (AtlasObjectId) o; - - if (typeName != null ? !typeName.equals(that.typeName) : that.typeName != null) { return false; } - if (guid != null ? !guid.equals(that.guid) : that.guid != null) { return false; } - - return true; + return Objects.equals(typeName, that.typeName) && + Objects.equals(guid, that.guid); } @Override public int hashCode() { - int result = typeName != null ? typeName.hashCode() : 0; - result = 31 * result + (guid != null ? guid.hashCode() : 0); - return result; + return Objects.hash(typeName, guid); } @Override http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/intg/src/main/java/org/apache/atlas/model/instance/AtlasStruct.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/model/instance/AtlasStruct.java b/intg/src/main/java/org/apache/atlas/model/instance/AtlasStruct.java index 695f1bb..41385f5 100644 --- a/intg/src/main/java/org/apache/atlas/model/instance/AtlasStruct.java +++ b/intg/src/main/java/org/apache/atlas/model/instance/AtlasStruct.java @@ -25,6 +25,7 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; @@ -142,22 +143,16 @@ public class AtlasStruct implements Serializable { @Override public boolean equals(Object o) { - if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { return false; } - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; AtlasStruct that = (AtlasStruct) o; - - if (typeName != null ? !typeName.equals(that.typeName) : that.typeName != null) { return false; } - if (attributes != null ? !attributes.equals(that.attributes) : that.attributes != null) { return false; } - - return true; + return Objects.equals(typeName, that.typeName) && + Objects.equals(attributes, that.attributes); } @Override public int hashCode() { - int result = (typeName != null ? typeName.hashCode() : 0); - result = 31 * result + (attributes != null ? attributes.hashCode() : 0); - return result; + return Objects.hash(typeName, attributes); } @Override http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/intg/src/main/java/org/apache/atlas/model/instance/EntityMutationResponse.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/model/instance/EntityMutationResponse.java b/intg/src/main/java/org/apache/atlas/model/instance/EntityMutationResponse.java index 72f4118..45efb04 100644 --- a/intg/src/main/java/org/apache/atlas/model/instance/EntityMutationResponse.java +++ b/intg/src/main/java/org/apache/atlas/model/instance/EntityMutationResponse.java @@ -33,6 +33,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY; @@ -109,24 +110,15 @@ public class EntityMutationResponse { @Override public boolean equals(Object o) { - if ( this == o) return true; - - if ( this == null || getClass() != o.getClass()) return false; - if ( !super.equals(o)) return false; - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; EntityMutationResponse that = (EntityMutationResponse) o; - - if ( entitiesMutated != null ? !entitiesMutated.equals(that.entitiesMutated) : that.entitiesMutated != null) { - return false; - } - - return true; + return Objects.equals(entitiesMutated, that.entitiesMutated); } @Override public int hashCode() { - int result = (entitiesMutated != null ? entitiesMutated.hashCode() : 0); - return result; + return Objects.hash(entitiesMutated); } @Override http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/intg/src/main/java/org/apache/atlas/model/instance/EntityMutations.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/model/instance/EntityMutations.java b/intg/src/main/java/org/apache/atlas/model/instance/EntityMutations.java index e489f33..6119daf 100644 --- a/intg/src/main/java/org/apache/atlas/model/instance/EntityMutations.java +++ b/intg/src/main/java/org/apache/atlas/model/instance/EntityMutations.java @@ -29,6 +29,7 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Objects; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY; @@ -74,22 +75,16 @@ public class EntityMutations implements Serializable { @Override public boolean equals(Object o) { - if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { return false; } - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; EntityMutation that = (EntityMutation) o; - - if (op != null ? !op.equals(that.op) : that.op != null) { return false; } - if (entity != null ? !entity.equals(that.entity) : that.entity != null) { return false; } - - return true; + return op == that.op && + Objects.equals(entity, that.entity); } @Override public int hashCode() { - int result = (op != null ? op.hashCode() : 0); - result = 31 * result + (entity != null ? entity.hashCode() : 0); - return result; + return Objects.hash(op, entity); } @Override @@ -125,22 +120,18 @@ public class EntityMutations implements Serializable { return toString(new StringBuilder()).toString(); } + @Override public boolean equals(Object o) { - if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { return false; } - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; EntityMutations that = (EntityMutations) o; - - if (entityMutations != null ? !entityMutations.equals(that.entityMutations) : that.entityMutations != null) { return false; } - - return true; + return Objects.equals(entityMutations, that.entityMutations); } @Override public int hashCode() { - int result = (entityMutations != null ? entityMutations.hashCode() : 0); - return result; + return Objects.hash(entityMutations); } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/intg/src/main/java/org/apache/atlas/model/lineage/AtlasLineageInfo.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/model/lineage/AtlasLineageInfo.java b/intg/src/main/java/org/apache/atlas/model/lineage/AtlasLineageInfo.java index 61b7f91..561ece5 100644 --- a/intg/src/main/java/org/apache/atlas/model/lineage/AtlasLineageInfo.java +++ b/intg/src/main/java/org/apache/atlas/model/lineage/AtlasLineageInfo.java @@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlRootElement; import java.io.Serializable; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE; @@ -111,24 +112,17 @@ public class AtlasLineageInfo implements Serializable { public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - AtlasLineageInfo that = (AtlasLineageInfo) o; - - if (baseEntityGuid != null ? !baseEntityGuid.equals(that.baseEntityGuid) : that.baseEntityGuid != null) return false; - if (lineageDepth != that.lineageDepth) return false; - if (guidEntityMap != null ? !guidEntityMap.equals(that.guidEntityMap) : that.guidEntityMap != null) return false; - if (relations != null ? !relations.equals(that.relations) : that.relations != null) return false; - return lineageDirection == that.lineageDirection; + return lineageDepth == that.lineageDepth && + Objects.equals(baseEntityGuid, that.baseEntityGuid) && + lineageDirection == that.lineageDirection && + Objects.equals(guidEntityMap, that.guidEntityMap) && + Objects.equals(relations, that.relations); } @Override public int hashCode() { - int result = guidEntityMap != null ? guidEntityMap.hashCode() : 0; - result = 31 * result + (relations != null ? relations.hashCode() : 0); - result = 31 * result + (lineageDirection != null ? lineageDirection.hashCode() : 0); - result = 31 * result + lineageDepth; - result = 31 * result + (baseEntityGuid != null ? baseEntityGuid.hashCode() : 0); - return result; + return Objects.hash(baseEntityGuid, lineageDirection, lineageDepth, guidEntityMap, relations); } @Override @@ -178,20 +172,14 @@ public class AtlasLineageInfo implements Serializable { public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - LineageRelation that = (LineageRelation) o; - - if (fromEntityId != null ? !fromEntityId.equals(that.fromEntityId) : that.fromEntityId != null) - return false; - return toEntityId != null ? toEntityId.equals(that.toEntityId) : that.toEntityId == null; - + return Objects.equals(fromEntityId, that.fromEntityId) && + Objects.equals(toEntityId, that.toEntityId); } @Override public int hashCode() { - int result = fromEntityId != null ? fromEntityId.hashCode() : 0; - result = 31 * result + (toEntityId != null ? toEntityId.hashCode() : 0); - return result; + return Objects.hash(fromEntityId, toEntityId); } @Override http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/intg/src/main/java/org/apache/atlas/model/typedef/AtlasBaseTypeDef.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/model/typedef/AtlasBaseTypeDef.java b/intg/src/main/java/org/apache/atlas/model/typedef/AtlasBaseTypeDef.java index feae00d..e2d6181 100644 --- a/intg/src/main/java/org/apache/atlas/model/typedef/AtlasBaseTypeDef.java +++ b/intg/src/main/java/org/apache/atlas/model/typedef/AtlasBaseTypeDef.java @@ -17,25 +17,26 @@ */ package org.apache.atlas.model.typedef; +import org.apache.atlas.model.TypeCategory; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.MapUtils; +import org.codehaus.jackson.annotate.JsonAutoDetect; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.codehaus.jackson.map.annotate.JsonSerialize; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Collection; import java.util.Date; import java.util.HashMap; import java.util.Map; +import java.util.Objects; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; - -import org.apache.atlas.model.TypeCategory; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.MapUtils; -import org.codehaus.jackson.annotate.JsonAutoDetect; -import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE; -import org.codehaus.jackson.annotate.JsonIgnoreProperties; -import org.codehaus.jackson.map.annotate.JsonSerialize; +import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY; /** @@ -279,24 +280,20 @@ public abstract class AtlasBaseTypeDef implements java.io.Serializable { @Override public boolean equals(Object o) { - if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { return false; } - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; AtlasBaseTypeDef that = (AtlasBaseTypeDef) o; - if (category != null ? !category.equals(that.category) : that.category != null) { return false; } - if (guid != null ? !guid.equals(that.guid) : that.guid != null) { return false; } - if (createdBy != null ? !createdBy.equals(that.createdBy) : that.createdBy != null) { return false; } - if (updatedBy != null ? !updatedBy.equals(that.updatedBy) : that.updatedBy != null) { return false; } - if (createTime != null ? !createTime.equals(that.createTime) : that.createTime != null) { return false; } - if (updateTime != null ? !updateTime.equals(that.updateTime) : that.updateTime != null) { return false; } - if (version != null ? !version.equals(that.version) : that.version != null) { return false; } - if (name != null ? !name.equals(that.name) : that.name != null) { return false; } - if (description != null ? !description.equals(that.description) : that.description != null) { return false; } - if (typeVersion != null ? !typeVersion.equals(that.typeVersion) : that.typeVersion != null) { return false; } - if (options != null ? !options.equals(that.options) : that.options != null) { return false; } - - return true; + return category == that.category && + Objects.equals(guid, that.guid) && + Objects.equals(createdBy, that.createdBy) && + Objects.equals(updatedBy, that.updatedBy) && + Objects.equals(createTime, that.createTime) && + Objects.equals(updateTime, that.updateTime) && + Objects.equals(version, that.version) && + Objects.equals(name, that.name) && + Objects.equals(description, that.description) && + Objects.equals(typeVersion, that.typeVersion); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/intg/src/main/java/org/apache/atlas/model/typedef/AtlasClassificationDef.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/model/typedef/AtlasClassificationDef.java b/intg/src/main/java/org/apache/atlas/model/typedef/AtlasClassificationDef.java index 1be5ee1..7032182 100644 --- a/intg/src/main/java/org/apache/atlas/model/typedef/AtlasClassificationDef.java +++ b/intg/src/main/java/org/apache/atlas/model/typedef/AtlasClassificationDef.java @@ -17,26 +17,27 @@ */ package org.apache.atlas.model.typedef; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlSeeAlso; - import org.apache.atlas.model.PList; import org.apache.atlas.model.SearchFilter.SortType; import org.apache.atlas.model.TypeCategory; import org.apache.commons.collections.CollectionUtils; import org.codehaus.jackson.annotate.JsonAutoDetect; -import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY; -import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.map.annotate.JsonSerialize; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSeeAlso; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE; +import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY; + /** * class that captures details of a classification-type. @@ -163,17 +164,12 @@ public class AtlasClassificationDef extends AtlasStructDef implements java.io.Se if (!super.equals(o)) { return false; } AtlasClassificationDef that = (AtlasClassificationDef) o; - - if (superTypes != null ? !superTypes.equals(that.superTypes) : that.superTypes != null) { return false; } - - return true; + return Objects.equals(superTypes, that.superTypes); } @Override public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (superTypes != null ? superTypes.hashCode() : 0); - return result; + return Objects.hash(super.hashCode(), superTypes); } @Override http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/intg/src/main/java/org/apache/atlas/model/typedef/AtlasEntityDef.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/model/typedef/AtlasEntityDef.java b/intg/src/main/java/org/apache/atlas/model/typedef/AtlasEntityDef.java index 0312176..480b27b 100644 --- a/intg/src/main/java/org/apache/atlas/model/typedef/AtlasEntityDef.java +++ b/intg/src/main/java/org/apache/atlas/model/typedef/AtlasEntityDef.java @@ -17,26 +17,27 @@ */ package org.apache.atlas.model.typedef; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlSeeAlso; - import org.apache.atlas.model.PList; import org.apache.atlas.model.SearchFilter.SortType; import org.apache.atlas.model.TypeCategory; import org.apache.commons.collections.CollectionUtils; import org.codehaus.jackson.annotate.JsonAutoDetect; -import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY; -import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.map.annotate.JsonSerialize; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSeeAlso; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE; +import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY; + /** * class that captures details of a entity-type. @@ -161,17 +162,12 @@ public class AtlasEntityDef extends AtlasStructDef implements java.io.Serializab if (!super.equals(o)) { return false; } AtlasEntityDef that = (AtlasEntityDef) o; - - if (superTypes != null ? !superTypes.equals(that.superTypes) : that.superTypes != null) { return false; } - - return true; + return Objects.equals(superTypes, that.superTypes); } @Override public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (superTypes != null ? superTypes.hashCode() : 0); - return result; + return Objects.hash(super.hashCode(), superTypes); } @Override http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/intg/src/main/java/org/apache/atlas/model/typedef/AtlasEnumDef.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/model/typedef/AtlasEnumDef.java b/intg/src/main/java/org/apache/atlas/model/typedef/AtlasEnumDef.java index f486f9b..69d7b30 100644 --- a/intg/src/main/java/org/apache/atlas/model/typedef/AtlasEnumDef.java +++ b/intg/src/main/java/org/apache/atlas/model/typedef/AtlasEnumDef.java @@ -222,22 +222,17 @@ public class AtlasEnumDef extends AtlasBaseTypeDef implements Serializable { @Override public boolean equals(Object o) { - if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { return false; } - if (!super.equals(o)) { return false; } - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; AtlasEnumDef that = (AtlasEnumDef) o; - - if (elementDefs != null ? !elementDefs.equals(that.elementDefs) : that.elementDefs != null) { return false; } - - return true; + return Objects.equals(elementDefs, that.elementDefs) && + Objects.equals(defaultValue, that.defaultValue); } @Override public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (elementDefs != null ? elementDefs.hashCode() : 0); - return result; + return Objects.hash(super.hashCode(), elementDefs, defaultValue); } @Override @@ -319,26 +314,17 @@ public class AtlasEnumDef extends AtlasBaseTypeDef implements Serializable { @Override public boolean equals(Object o) { - if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { return false; } - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; AtlasEnumElementDef that = (AtlasEnumElementDef) o; - - if (value != null ? !value.equals(that.value) : that.value != null) { return false; } - if (description != null ? !description.equals(that.description) : that.description != null) { - return false; - } - if (ordinal != null ? !ordinal.equals(that.ordinal) : that.ordinal != null) { return false; } - - return true; + return Objects.equals(value, that.value) && + Objects.equals(description, that.description) && + Objects.equals(ordinal, that.ordinal); } @Override public int hashCode() { - int result = value != null ? value.hashCode() : 0; - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + (ordinal != null ? ordinal.hashCode() : 0); - return result; + return Objects.hash(value, description, ordinal); } @Override http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/intg/src/main/java/org/apache/atlas/model/typedef/AtlasStructDef.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/model/typedef/AtlasStructDef.java b/intg/src/main/java/org/apache/atlas/model/typedef/AtlasStructDef.java index 16e0344..4de7179 100644 --- a/intg/src/main/java/org/apache/atlas/model/typedef/AtlasStructDef.java +++ b/intg/src/main/java/org/apache/atlas/model/typedef/AtlasStructDef.java @@ -25,6 +25,7 @@ import java.util.HashSet; import java.util.List; import java.util.ListIterator; import java.util.Map; +import java.util.Objects; import java.util.Set; import javax.xml.bind.annotation.XmlAccessType; @@ -224,24 +225,16 @@ public class AtlasStructDef extends AtlasBaseTypeDef implements Serializable { @Override public boolean equals(Object o) { - if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { return false; } - if (!super.equals(o)) { return false; } - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; AtlasStructDef that = (AtlasStructDef) o; - - if (attributeDefs != null ? !attributeDefs.equals(that.attributeDefs) : that.attributeDefs != null) { - return false; - } - - return true; + return Objects.equals(attributeDefs, that.attributeDefs); } @Override public int hashCode() { - int result = super.hashCode(); - result = 31 * result + (attributeDefs != null ? attributeDefs.hashCode() : 0); - return result; + return Objects.hash(super.hashCode(), attributeDefs); } @Override @@ -433,40 +426,23 @@ public class AtlasStructDef extends AtlasBaseTypeDef implements Serializable { @Override public boolean equals(Object o) { - if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { return false; } - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; AtlasAttributeDef that = (AtlasAttributeDef) o; - - if (name != null ? !name.equals(that.name) : that.name != null) { return false; } - if (typeName != null ? !typeName.equals(that.typeName) : that.typeName != null) { return false; } - if (isOptional != that.isOptional) { return false; } - if (cardinality != null ? !cardinality.equals(that.cardinality) : that.cardinality != null) { - return false; - } - if (valuesMinCount != that.valuesMinCount) { return false; } - if (valuesMaxCount != that.valuesMaxCount) { return false; } - if (isUnique != that.isUnique) { return false; } - if (isIndexable != that.isIndexable) { return false; } - if (constraintDefs != null ? !constraintDefs.equals(that.constraintDefs) : that.constraintDefs != null) { - return false; - } - - return true; + return isOptional == that.isOptional && + valuesMinCount == that.valuesMinCount && + valuesMaxCount == that.valuesMaxCount && + isUnique == that.isUnique && + isIndexable == that.isIndexable && + Objects.equals(name, that.name) && + Objects.equals(typeName, that.typeName) && + cardinality == that.cardinality && + Objects.equals(constraintDefs, that.constraintDefs); } @Override public int hashCode() { - int result = name != null ? name.hashCode() : 0; - result = 31 * result + (typeName != null ? typeName.hashCode() : 0); - result = 31 * result + (isOptional ? 1 : 0); - result = 31 * result + (cardinality != null ? cardinality.hashCode() : 0); - result = 31 * result + valuesMinCount; - result = 31 * result + valuesMaxCount; - result = 31 * result + (isUnique ? 1 : 0); - result = 31 * result + (isIndexable ? 1 : 0); - result = 31 * result + (constraintDefs != null ? constraintDefs.hashCode() : 0); - return result; + return Objects.hash(name, typeName, isOptional, cardinality, valuesMinCount, valuesMaxCount, isUnique, isIndexable, constraintDefs); } @Override @@ -553,20 +529,14 @@ public class AtlasStructDef extends AtlasBaseTypeDef implements Serializable { public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - AtlasConstraintDef that = (AtlasConstraintDef) o; - - if (type != null ? !type.equals(that.type) : that.type != null) return false; - if (params != null ? !params.equals(that.params) : that.params != null) return false; - - return true; + return Objects.equals(type, that.type) && + Objects.equals(params, that.params); } @Override public int hashCode() { - int result = type != null ? type.hashCode() : 0; - result = 31 * result + (params != null ? params.hashCode() : 0); - return result; + return Objects.hash(type, params); } @Override http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/intg/src/main/java/org/apache/atlas/model/typedef/AtlasTypeDefHeader.java ---------------------------------------------------------------------- diff --git a/intg/src/main/java/org/apache/atlas/model/typedef/AtlasTypeDefHeader.java b/intg/src/main/java/org/apache/atlas/model/typedef/AtlasTypeDefHeader.java index a3929b3..23b6345 100644 --- a/intg/src/main/java/org/apache/atlas/model/typedef/AtlasTypeDefHeader.java +++ b/intg/src/main/java/org/apache/atlas/model/typedef/AtlasTypeDefHeader.java @@ -26,6 +26,8 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; +import java.util.Objects; + import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY; @@ -101,24 +103,17 @@ public class AtlasTypeDefHeader implements java.io.Serializable { @Override public boolean equals(Object o) { - if (this == o) { return true; } - if (o == null || getClass() != o.getClass()) { return false; } - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; AtlasTypeDefHeader that = (AtlasTypeDefHeader) o; - - if (guid != null ? !guid.equals(that.guid) : that.guid != null) { return false; } - if (name != null ? !name.equals(that.name) : that.name != null) { return false; } - if (category != null ? !category.equals(that.category) : that.category != null) { return false; } - - return true; + return Objects.equals(guid, that.guid) && + Objects.equals(name, that.name) && + category == that.category; } @Override public int hashCode() { - int result = guid != null ? guid.hashCode() : 0; - result = 31 * result + (name != null ? name.hashCode() : 0); - result = 31 * result + (category != null ? category.hashCode() : 0); - return result; + return Objects.hash(guid, name, category); } public StringBuilder toString(StringBuilder sb) { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotificationImpl.java ---------------------------------------------------------------------- diff --git a/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotificationImpl.java b/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotificationImpl.java index fda588e..6a9b362 100644 --- a/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotificationImpl.java +++ b/notification/src/main/java/org/apache/atlas/notification/entity/EntityNotificationImpl.java @@ -31,6 +31,7 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; /** @@ -106,25 +107,17 @@ public class EntityNotificationImpl implements EntityNotification { @Override public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; EntityNotificationImpl that = (EntityNotificationImpl) o; - - return !(entity != null ? !entity.equals(that.entity) : that.entity != null) - && operationType == that.operationType && traits.equals(that.traits); + return Objects.equals(entity, that.entity) && + operationType == that.operationType && + Objects.equals(traits, that.traits); } @Override public int hashCode() { - int result = entity != null ? entity.hashCode() : 0; - result = 31 * result + operationType.hashCode(); - result = 31 * result + traits.hashCode(); - return result; + return Objects.hash(entity, operationType, traits); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/notification/src/test/java/org/apache/atlas/notification/AbstractNotificationConsumerTest.java ---------------------------------------------------------------------- diff --git a/notification/src/test/java/org/apache/atlas/notification/AbstractNotificationConsumerTest.java b/notification/src/test/java/org/apache/atlas/notification/AbstractNotificationConsumerTest.java index ed5b9fc..13f2f0b 100644 --- a/notification/src/test/java/org/apache/atlas/notification/AbstractNotificationConsumerTest.java +++ b/notification/src/test/java/org/apache/atlas/notification/AbstractNotificationConsumerTest.java @@ -26,6 +26,7 @@ import org.testng.annotations.Test; import java.lang.reflect.Type; import java.util.LinkedList; import java.util.List; +import java.util.Objects; import static org.mockito.Matchers.endsWith; import static org.mockito.Mockito.mock; @@ -214,23 +215,16 @@ public class AbstractNotificationConsumerTest { @Override public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; TestMessage that = (TestMessage) o; - - return i == that.i && (s != null ? s.equals(that.s) : that.s == null); + return i == that.i && + Objects.equals(s, that.s); } @Override public int hashCode() { - int result = s != null ? s.hashCode() : 0; - result = 31 * result + i; - return result; + return Objects.hash(s, i); } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/release-log.txt ---------------------------------------------------------------------- diff --git a/release-log.txt b/release-log.txt index b8786ad..6f46fa5 100644 --- a/release-log.txt +++ b/release-log.txt @@ -9,6 +9,7 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai) ALL CHANGES: +ATLAS-1303 Update hashCode and equals method to use standard JDK libraries (apoorvnaik via svimal2106) ATLAS-1364 HiveHook : Fix Auth issue with doAs (sumasai) ATLAS-1340 Credential Provider utility does not work with fully qualified local/HDFS jceks path (vrathor via svimal2106) ATLAS-1363 Upgrade front end maven plugin to 1.0 (sumasai) http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java index cdeb117..cb54c3e 100755 --- a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java +++ b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java @@ -58,15 +58,7 @@ import org.codehaus.jettison.json.JSONArray; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.Stack; -import java.util.UUID; +import java.util.*; /** * Utility class for graph operations. @@ -607,31 +599,18 @@ public final class GraphHelper { } @Override - public int hashCode() { - - final int prime = 31; - int result = 1; - result = prime * result + ((guid == null) ? 0 : guid.hashCode()); - result = prime * result + ((vertex == null) ? 0 : vertex.hashCode()); - return result; + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + VertexInfo that = (VertexInfo) o; + return Objects.equals(guid, that.guid) && + Objects.equals(vertex, that.vertex) && + Objects.equals(typeName, that.typeName); } @Override - public boolean equals(Object obj) { - - if (this == obj) - return true; - if (obj == null) - return false; - if (!(obj instanceof VertexInfo)) - return false; - VertexInfo other = (VertexInfo)obj; - if (guid == null) { - if (other.guid != null) - return false; - } else if (!guid.equals(other.guid)) - return false; - return true; + public int hashCode() { + return Objects.hash(guid, vertex, typeName); } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/typesystem/src/main/java/org/apache/atlas/typesystem/Referenceable.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/Referenceable.java b/typesystem/src/main/java/org/apache/atlas/typesystem/Referenceable.java index 0b3ffe3..401df5f 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/Referenceable.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/Referenceable.java @@ -28,6 +28,7 @@ import org.apache.atlas.typesystem.persistence.Id; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; /** * Represents a Class Instance that has not been associated with a FieldMapping. @@ -158,6 +159,21 @@ public class Referenceable extends Struct implements IReferenceableInstance { return systemAttributes; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Referenceable that = (Referenceable) o; + return Objects.equals(id, that.id) && + Objects.equals(traits, that.traits) && + Objects.equals(traitNames, that.traitNames); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), id, traits, traitNames); + } + /** * Matches traits, values associated with this Referenceable and skips the id match * @param o The Referenceable which needs to be matched with http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java index a3f9421..4a90eb2 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/persistence/Id.java @@ -32,6 +32,7 @@ import java.nio.charset.Charset; import java.security.MessageDigest; import java.util.Date; import java.util.Map; +import java.util.Objects; import java.util.UUID; import java.util.concurrent.atomic.AtomicLong; @@ -134,34 +135,18 @@ public class Id implements ITypedReferenceableInstance { @Override public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; Id id1 = (Id) o; - - if (version != id1.version) { - return false; - } - if (!typeName.equals(id1.typeName)) { - return false; - } - if (!id.equals(id1.id)) { - return false; - } - - return true; + return version == id1.version && + Objects.equals(id, id1.id) && + Objects.equals(typeName, id1.typeName) && + state == id1.state; } @Override public int hashCode() { - int result = id.hashCode(); - result = 31 * result + typeName.hashCode(); - result = 31 * result + version; - return result; + return Objects.hash(id, typeName, version, state); } @Override http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeDefinition.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeDefinition.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeDefinition.java index f556223..5561f0b 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeDefinition.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeDefinition.java @@ -20,6 +20,8 @@ package org.apache.atlas.typesystem.types; import org.apache.atlas.utils.ParamChecker; +import java.util.Objects; + public final class AttributeDefinition { public final String name; @@ -55,51 +57,21 @@ public final class AttributeDefinition { @Override public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; AttributeDefinition that = (AttributeDefinition) o; - - if (isComposite != that.isComposite) { - return false; - } - if (isUnique != that.isUnique) { - return false; - } - if (isIndexable != that.isIndexable) { - return false; - } - if (!dataTypeName.equals(that.dataTypeName)) { - return false; - } - if (!multiplicity.equals(that.multiplicity)) { - return false; - } - if (!name.equals(that.name)) { - return false; - } - if (reverseAttributeName != null ? !reverseAttributeName.equals(that.reverseAttributeName) : - that.reverseAttributeName != null) { - return false; - } - - return true; + return isComposite == that.isComposite && + isUnique == that.isUnique && + isIndexable == that.isIndexable && + Objects.equals(name, that.name) && + Objects.equals(dataTypeName, that.dataTypeName) && + Objects.equals(multiplicity, that.multiplicity) && + Objects.equals(reverseAttributeName, that.reverseAttributeName); } @Override public int hashCode() { - int result = name.hashCode(); - result = 31 * result + dataTypeName.hashCode(); - result = 31 * result + multiplicity.hashCode(); - result = 31 * result + (isComposite ? 1 : 0); - result = 31 * result + (isUnique ? 1 : 0); - result = 31 * result + (isIndexable ? 1 : 0); - result = 31 * result + (reverseAttributeName != null ? reverseAttributeName.hashCode() : 0); - return result; + return Objects.hash(name, dataTypeName, multiplicity, isComposite, isUnique, isIndexable, reverseAttributeName); } @Override http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeInfo.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeInfo.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeInfo.java index 9cb0d0d..35a45b9 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeInfo.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/AttributeInfo.java @@ -25,6 +25,7 @@ import org.codehaus.jettison.json.JSONObject; import java.io.IOException; import java.util.HashSet; import java.util.Map; +import java.util.Objects; import java.util.Set; public class AttributeInfo { @@ -90,40 +91,22 @@ public class AttributeInfo { } @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } + public int hashCode() { + return Objects.hash(name, multiplicity, isComposite, isUnique, isIndexable, reverseAttributeName, dataType); + } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; AttributeInfo that = (AttributeInfo) o; - - if (isComposite != that.isComposite) { - return false; - } - if (isUnique != that.isUnique) { - return false; - } - if (isIndexable != that.isIndexable) { - return false; - } - if (!dataType.getName().equals(that.dataType.getName())) { - return false; - } - if (!multiplicity.equals(that.multiplicity)) { - return false; - } - if (!name.equals(that.name)) { - return false; - } - if (reverseAttributeName != null ? !reverseAttributeName.equals(that.reverseAttributeName) : - that.reverseAttributeName != null) { - return false; - } - - return true; + return isComposite == that.isComposite && + isUnique == that.isUnique && + isIndexable == that.isIndexable && + Objects.equals(name, that.name) && + Objects.equals(multiplicity, that.multiplicity) && + Objects.equals(reverseAttributeName, that.reverseAttributeName) && + Objects.equals(dataType, that.dataType); } public String toJson() throws JSONException { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumTypeDefinition.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumTypeDefinition.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumTypeDefinition.java index ac3b5a3..40cb132 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumTypeDefinition.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/EnumTypeDefinition.java @@ -22,6 +22,7 @@ import org.apache.atlas.utils.ParamChecker; import org.apache.atlas.AtlasConstants; import java.util.Arrays; +import java.util.Objects; public final class EnumTypeDefinition { @@ -47,29 +48,17 @@ public final class EnumTypeDefinition { @Override public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; EnumTypeDefinition that = (EnumTypeDefinition) o; - - if (!Arrays.equals(enumValues, that.enumValues)) { - return false; - } - if (!name.equals(that.name)) { - return false; - } - - return true; + return Objects.equals(name, that.name) && + Objects.equals(description, that.description) && + Objects.equals(version, that.version) && + Arrays.equals(enumValues, that.enumValues); } @Override public int hashCode() { - int result = name.hashCode(); - result = 31 * result + Arrays.hashCode(enumValues); - return result; + return Objects.hash(name, description, version, enumValues); } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalTypeDefinition.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalTypeDefinition.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalTypeDefinition.java index 8069422..ab63fea 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalTypeDefinition.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/HierarchicalTypeDefinition.java @@ -18,12 +18,10 @@ package org.apache.atlas.typesystem.types; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; - import org.apache.atlas.AtlasConstants; -import org.apache.atlas.classification.InterfaceAudience; -import org.apache.atlas.utils.ParamChecker; + +import java.util.Objects; public class HierarchicalTypeDefinition<T extends HierarchicalType> extends StructTypeDefinition { @@ -61,33 +59,16 @@ public class HierarchicalTypeDefinition<T extends HierarchicalType> extends Stru @Override public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - if (!super.equals(o)) { - return false; - } - - HierarchicalTypeDefinition that = (HierarchicalTypeDefinition) o; - - if (!hierarchicalMetaTypeName.equals(that.hierarchicalMetaTypeName)) { - return false; - } - if (!superTypes.equals(that.superTypes)) { - return false; - } - - return true; + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + HierarchicalTypeDefinition<?> that = (HierarchicalTypeDefinition<?>) o; + return Objects.equals(superTypes, that.superTypes) && + Objects.equals(hierarchicalMetaTypeName, that.hierarchicalMetaTypeName); } @Override public int hashCode() { - int result = super.hashCode(); - result = 31 * result + superTypes.hashCode(); - result = 31 * result + hierarchicalMetaTypeName.hashCode(); - return result; + return Objects.hash(super.hashCode(), superTypes, hierarchicalMetaTypeName); } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/typesystem/src/main/java/org/apache/atlas/typesystem/types/Multiplicity.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/Multiplicity.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/Multiplicity.java index 18ef2ee..c213d75 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/Multiplicity.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/Multiplicity.java @@ -21,6 +21,8 @@ package org.apache.atlas.typesystem.types; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; +import java.util.Objects; + public final class Multiplicity { public static final Multiplicity OPTIONAL = new Multiplicity(0, 1, false); @@ -52,34 +54,17 @@ public final class Multiplicity { @Override public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; Multiplicity that = (Multiplicity) o; - - if (isUnique != that.isUnique) { - return false; - } - if (lower != that.lower) { - return false; - } - if (upper != that.upper) { - return false; - } - - return true; + return lower == that.lower && + upper == that.upper && + isUnique == that.isUnique; } @Override public int hashCode() { - int result = lower; - result = 31 * result + upper; - result = 31 * result + (isUnique ? 1 : 0); - return result; + return Objects.hash(lower, upper, isUnique); } @Override http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/typesystem/src/main/java/org/apache/atlas/typesystem/types/StructTypeDefinition.java ---------------------------------------------------------------------- diff --git a/typesystem/src/main/java/org/apache/atlas/typesystem/types/StructTypeDefinition.java b/typesystem/src/main/java/org/apache/atlas/typesystem/types/StructTypeDefinition.java index c9316cc..4f8695b 100755 --- a/typesystem/src/main/java/org/apache/atlas/typesystem/types/StructTypeDefinition.java +++ b/typesystem/src/main/java/org/apache/atlas/typesystem/types/StructTypeDefinition.java @@ -22,6 +22,7 @@ import org.apache.atlas.AtlasConstants; import org.apache.atlas.utils.ParamChecker; import java.util.Arrays; +import java.util.Objects; public class StructTypeDefinition { @@ -65,31 +66,19 @@ public class StructTypeDefinition { } - @Override public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; StructTypeDefinition that = (StructTypeDefinition) o; - - if (!Arrays.equals(attributeDefinitions, that.attributeDefinitions)) { - return false; - } - if (!typeName.equals(that.typeName)) { - return false; - } - return true; + return Objects.equals(typeName, that.typeName) && + Objects.equals(typeDescription, that.typeDescription) && + Objects.equals(typeVersion, that.typeVersion) && + Arrays.equals(attributeDefinitions, that.attributeDefinitions); } @Override public int hashCode() { - int result = typeName.hashCode(); - result = 31 * result + Arrays.hashCode(attributeDefinitions); - return result; + return Objects.hash(typeName, typeDescription, typeVersion, attributeDefinitions); } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/3bffc0dc/webapp/src/main/java/org/apache/atlas/web/params/AbstractParam.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/params/AbstractParam.java b/webapp/src/main/java/org/apache/atlas/web/params/AbstractParam.java index 9cfdb76..8087782 100755 --- a/webapp/src/main/java/org/apache/atlas/web/params/AbstractParam.java +++ b/webapp/src/main/java/org/apache/atlas/web/params/AbstractParam.java @@ -21,6 +21,7 @@ package org.apache.atlas.web.params; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import java.util.Objects; /** * An abstract base class from which to build Jersey parameter classes. @@ -111,20 +112,16 @@ public abstract class AbstractParam<T> { } @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if ((obj == null) || (getClass() != obj.getClass())) { - return false; - } - final AbstractParam<?> that = (AbstractParam<?>) obj; - return value.equals(that.value); + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + AbstractParam<?> that = (AbstractParam<?>) o; + return Objects.equals(value, that.value); } @Override public int hashCode() { - return value.hashCode(); + return Objects.hash(value); } @Override
