Commit 3bffc0dc by apoorvnaik Committed by Vimal Sharma

Update hashCode and equals method to use standard JDK libraries

parent ed4ae0e3
...@@ -22,6 +22,7 @@ import java.util.Collection; ...@@ -22,6 +22,7 @@ import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Objects;
/** /**
* Base user API request. * Base user API request.
...@@ -75,25 +76,20 @@ public abstract class BaseRequest implements Request { ...@@ -75,25 +76,20 @@ public abstract class BaseRequest implements Request {
return additionalSelectProperties; return additionalSelectProperties;
} }
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
BaseRequest that = (BaseRequest) o; BaseRequest that = (BaseRequest) o;
return Objects.equals(queryProperties, that.queryProperties) &&
return queryProperties.equals(that.queryProperties) && Objects.equals(updateProperties, that.updateProperties) &&
updateProperties.equals(that.updateProperties) && Objects.equals(queryString, that.queryString) &&
additionalSelectProperties.equals(that.additionalSelectProperties) && Objects.equals(additionalSelectProperties, that.additionalSelectProperties);
queryString == null ? that.queryString == null : queryString.equals(that.queryString);
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = queryProperties.hashCode(); return Objects.hash(queryProperties, updateProperties, queryString, additionalSelectProperties);
result = 31 * result + updateProperties.hashCode();
result = 31 * result + (queryString != null ? queryString.hashCode() : 0);
result = 31 * result + additionalSelectProperties.hashCode();
return result;
} }
} }
...@@ -22,6 +22,8 @@ import org.apache.atlas.typesystem.IReferenceableInstance; ...@@ -22,6 +22,8 @@ import org.apache.atlas.typesystem.IReferenceableInstance;
import org.apache.atlas.typesystem.json.InstanceSerialization; import org.apache.atlas.typesystem.json.InstanceSerialization;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import java.util.Objects;
/** /**
* Structure of entity audit event * Structure of entity audit event
*/ */
...@@ -52,28 +54,22 @@ public class EntityAuditEvent { ...@@ -52,28 +54,22 @@ public class EntityAuditEvent {
} }
@Override @Override
public boolean equals(Object other) { public boolean equals(Object o) {
if (this == other) { if (this == o) return true;
return true; if (o == null || getClass() != o.getClass()) return false;
} EntityAuditEvent that = (EntityAuditEvent) o;
return timestamp == that.timestamp &&
if (!(other instanceof EntityAuditEvent)) { Objects.equals(entityId, that.entityId) &&
return false; Objects.equals(user, that.user) &&
} action == that.action &&
Objects.equals(details, that.details) &&
EntityAuditEvent otherEvent = (EntityAuditEvent) other; Objects.equals(eventKey, that.eventKey) &&
return StringUtils.equals(entityId, otherEvent.entityId) && Objects.equals(entityDefinition, that.entityDefinition);
(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());
} }
@Override @Override
public int hashCode() { public int hashCode() {
return toString().hashCode(); return Objects.hash(entityId, timestamp, user, action, details, eventKey, entityDefinition);
} }
@Override @Override
......
...@@ -23,6 +23,7 @@ import org.apache.commons.configuration.Configuration; ...@@ -23,6 +23,7 @@ import org.apache.commons.configuration.Configuration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* A wrapper for getting configuration entries related to HighAvailability. * A wrapper for getting configuration entries related to HighAvailability.
...@@ -151,47 +152,21 @@ public final class HAConfiguration { ...@@ -151,47 +152,21 @@ public final class HAConfiguration {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { if (this == o) return true;
return true; if (o == null || getClass() != o.getClass()) return false;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ZookeeperProperties that = (ZookeeperProperties) o; ZookeeperProperties that = (ZookeeperProperties) o;
return retriesSleepTimeMillis == that.retriesSleepTimeMillis &&
if (retriesSleepTimeMillis != that.retriesSleepTimeMillis) { numRetries == that.numRetries &&
return false; sessionTimeout == that.sessionTimeout &&
} Objects.equals(connectString, that.connectString) &&
if (numRetries != that.numRetries) { Objects.equals(zkRoot, that.zkRoot) &&
return false; Objects.equals(acl, that.acl) &&
} Objects.equals(auth, that.auth);
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);
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = connectString.hashCode(); return Objects.hash(connectString, zkRoot, retriesSleepTimeMillis, numRetries, sessionTimeout, acl, auth);
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;
} }
public boolean hasAcl() { public boolean hasAcl() {
......
...@@ -17,28 +17,28 @@ ...@@ -17,28 +17,28 @@
*/ */
package org.apache.atlas.model.instance; 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.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong; 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 static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/** /**
...@@ -190,30 +190,18 @@ public class AtlasEntity extends AtlasStruct implements Serializable { ...@@ -190,30 +190,18 @@ public class AtlasEntity extends AtlasStruct implements Serializable {
if (!super.equals(o)) { return false; } if (!super.equals(o)) { return false; }
AtlasEntity that = (AtlasEntity) o; AtlasEntity that = (AtlasEntity) o;
return Objects.equals(guid, that.guid) &&
if (guid != null ? !guid.equals(that.guid) : that.guid != null) { return false; } status == that.status &&
if (status != null ? !status.equals(that.status) : that.status != null) { return false; } Objects.equals(createdBy, that.createdBy) &&
if (createdBy != null ? !createdBy.equals(that.createdBy) : that.createdBy != null) { return false; } Objects.equals(updatedBy, that.updatedBy) &&
if (updatedBy != null ? !updatedBy.equals(that.updatedBy) : that.updatedBy != null) { return false; } Objects.equals(createTime, that.createTime) &&
if (createTime != null ? !createTime.equals(that.createTime) : that.createTime != null) { return false; } Objects.equals(updateTime, that.updateTime) &&
if (updateTime != null ? !updateTime.equals(that.updateTime) : that.updateTime != null) { return false; } Objects.equals(version, that.version);
if (version != null ? !version.equals(that.version) : that.version != null) { return false; }
return true;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = super.hashCode(); return Objects.hash(super.hashCode(), guid, status, createdBy, updatedBy, createTime, updateTime, version);
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;
} }
@Override @Override
......
...@@ -21,6 +21,7 @@ import java.io.Serializable; ...@@ -21,6 +21,7 @@ import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
...@@ -123,27 +124,18 @@ public class AtlasEntityHeader extends AtlasStruct implements Serializable { ...@@ -123,27 +124,18 @@ public class AtlasEntityHeader extends AtlasStruct implements Serializable {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { return true; } if (this == o) return true;
if (o == null || getClass() != o.getClass()) { return false; } if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) { return false; } if (!super.equals(o)) return false;
AtlasEntityHeader that = (AtlasEntityHeader) o; AtlasEntityHeader that = (AtlasEntityHeader) o;
return Objects.equals(guid, that.guid) &&
if (guid != null ? !guid.equals(that.guid) : that.guid != null) { return false; } status == that.status &&
if (status != null ? !status.equals(that.status) : that.status != null) { return false; } Objects.equals(displayText, that.displayText);
if (displayText != null ? !displayText.equals(that.displayText) : that.displayText != null) { return false; }
return true;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = super.hashCode(); return Objects.hash(super.hashCode(), guid, status, displayText);
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;
} }
@Override @Override
......
...@@ -32,6 +32,7 @@ import java.io.Serializable; ...@@ -32,6 +32,7 @@ import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; 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.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
...@@ -90,15 +91,16 @@ public class AtlasEntityWithAssociations extends AtlasEntity implements Serializ ...@@ -90,15 +91,16 @@ public class AtlasEntityWithAssociations extends AtlasEntity implements Serializ
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { return true; } if (this == o) return true;
if (o == null || getClass() != o.getClass()) { return false; } if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) { return false; } if (!super.equals(o)) return false;
AtlasEntityWithAssociations that = (AtlasEntityWithAssociations) o; AtlasEntityWithAssociations that = (AtlasEntityWithAssociations) o;
return Objects.equals(classifications, that.classifications);
}
if (classifications != null ? !classifications.equals(that.classifications) : that.classifications != null) { return false; } @Override
public int hashCode() {
return true; return Objects.hash(super.hashCode(), classifications);
} }
public List<AtlasClassification> getClassifications() { public List<AtlasClassification> getClassifications() {
...@@ -110,13 +112,6 @@ public class AtlasEntityWithAssociations extends AtlasEntity implements Serializ ...@@ -110,13 +112,6 @@ public class AtlasEntityWithAssociations extends AtlasEntity implements Serializ
} }
@Override @Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (classifications != null ? classifications.hashCode() : 0);
return result;
}
@Override
public String toString() { public String toString() {
return toString(new StringBuilder()).toString(); return toString(new StringBuilder()).toString();
} }
......
...@@ -20,6 +20,7 @@ package org.apache.atlas.model.instance; ...@@ -20,6 +20,7 @@ package org.apache.atlas.model.instance;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
...@@ -118,22 +119,16 @@ public class AtlasObjectId implements Serializable { ...@@ -118,22 +119,16 @@ public class AtlasObjectId implements Serializable {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { return true; } if (this == o) return true;
if (o == null || getClass() != o.getClass()) { return false; } if (o == null || getClass() != o.getClass()) return false;
AtlasObjectId that = (AtlasObjectId) o; AtlasObjectId that = (AtlasObjectId) o;
return Objects.equals(typeName, that.typeName) &&
if (typeName != null ? !typeName.equals(that.typeName) : that.typeName != null) { return false; } Objects.equals(guid, that.guid);
if (guid != null ? !guid.equals(that.guid) : that.guid != null) { return false; }
return true;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = typeName != null ? typeName.hashCode() : 0; return Objects.hash(typeName, guid);
result = 31 * result + (guid != null ? guid.hashCode() : 0);
return result;
} }
@Override @Override
......
...@@ -25,6 +25,7 @@ import java.util.Date; ...@@ -25,6 +25,7 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
...@@ -142,22 +143,16 @@ public class AtlasStruct implements Serializable { ...@@ -142,22 +143,16 @@ public class AtlasStruct implements Serializable {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { return true; } if (this == o) return true;
if (o == null || getClass() != o.getClass()) { return false; } if (o == null || getClass() != o.getClass()) return false;
AtlasStruct that = (AtlasStruct) o; AtlasStruct that = (AtlasStruct) o;
return Objects.equals(typeName, that.typeName) &&
if (typeName != null ? !typeName.equals(that.typeName) : that.typeName != null) { return false; } Objects.equals(attributes, that.attributes);
if (attributes != null ? !attributes.equals(that.attributes) : that.attributes != null) { return false; }
return true;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = (typeName != null ? typeName.hashCode() : 0); return Objects.hash(typeName, attributes);
result = 31 * result + (attributes != null ? attributes.hashCode() : 0);
return result;
} }
@Override @Override
......
...@@ -33,6 +33,7 @@ import java.util.Collections; ...@@ -33,6 +33,7 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; 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.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
...@@ -109,24 +110,15 @@ public class EntityMutationResponse { ...@@ -109,24 +110,15 @@ public class EntityMutationResponse {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if ( this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if ( this == null || getClass() != o.getClass()) return false;
if ( !super.equals(o)) return false;
EntityMutationResponse that = (EntityMutationResponse) o; EntityMutationResponse that = (EntityMutationResponse) o;
return Objects.equals(entitiesMutated, that.entitiesMutated);
if ( entitiesMutated != null ? !entitiesMutated.equals(that.entitiesMutated) : that.entitiesMutated != null) {
return false;
}
return true;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = (entitiesMutated != null ? entitiesMutated.hashCode() : 0); return Objects.hash(entitiesMutated);
return result;
} }
@Override @Override
......
...@@ -29,6 +29,7 @@ import java.io.Serializable; ...@@ -29,6 +29,7 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; 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.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
...@@ -74,22 +75,16 @@ public class EntityMutations implements Serializable { ...@@ -74,22 +75,16 @@ public class EntityMutations implements Serializable {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { return true; } if (this == o) return true;
if (o == null || getClass() != o.getClass()) { return false; } if (o == null || getClass() != o.getClass()) return false;
EntityMutation that = (EntityMutation) o; EntityMutation that = (EntityMutation) o;
return op == that.op &&
if (op != null ? !op.equals(that.op) : that.op != null) { return false; } Objects.equals(entity, that.entity);
if (entity != null ? !entity.equals(that.entity) : that.entity != null) { return false; }
return true;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = (op != null ? op.hashCode() : 0); return Objects.hash(op, entity);
result = 31 * result + (entity != null ? entity.hashCode() : 0);
return result;
} }
@Override @Override
...@@ -125,22 +120,18 @@ public class EntityMutations implements Serializable { ...@@ -125,22 +120,18 @@ public class EntityMutations implements Serializable {
return toString(new StringBuilder()).toString(); return toString(new StringBuilder()).toString();
} }
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { return true; } if (this == o) return true;
if (o == null || getClass() != o.getClass()) { return false; } if (o == null || getClass() != o.getClass()) return false;
EntityMutations that = (EntityMutations) o; EntityMutations that = (EntityMutations) o;
return Objects.equals(entityMutations, that.entityMutations);
if (entityMutations != null ? !entityMutations.equals(that.entityMutations) : that.entityMutations != null) { return false; }
return true;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = (entityMutations != null ? entityMutations.hashCode() : 0); return Objects.hash(entityMutations);
return result;
} }
} }
......
...@@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlRootElement; ...@@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
...@@ -111,24 +112,17 @@ public class AtlasLineageInfo implements Serializable { ...@@ -111,24 +112,17 @@ public class AtlasLineageInfo implements Serializable {
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
AtlasLineageInfo that = (AtlasLineageInfo) o; AtlasLineageInfo that = (AtlasLineageInfo) o;
return lineageDepth == that.lineageDepth &&
if (baseEntityGuid != null ? !baseEntityGuid.equals(that.baseEntityGuid) : that.baseEntityGuid != null) return false; Objects.equals(baseEntityGuid, that.baseEntityGuid) &&
if (lineageDepth != that.lineageDepth) return false; lineageDirection == that.lineageDirection &&
if (guidEntityMap != null ? !guidEntityMap.equals(that.guidEntityMap) : that.guidEntityMap != null) return false; Objects.equals(guidEntityMap, that.guidEntityMap) &&
if (relations != null ? !relations.equals(that.relations) : that.relations != null) return false; Objects.equals(relations, that.relations);
return lineageDirection == that.lineageDirection;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = guidEntityMap != null ? guidEntityMap.hashCode() : 0; return Objects.hash(baseEntityGuid, lineageDirection, lineageDepth, guidEntityMap, relations);
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;
} }
@Override @Override
...@@ -178,20 +172,14 @@ public class AtlasLineageInfo implements Serializable { ...@@ -178,20 +172,14 @@ public class AtlasLineageInfo implements Serializable {
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
LineageRelation that = (LineageRelation) o; LineageRelation that = (LineageRelation) o;
return Objects.equals(fromEntityId, that.fromEntityId) &&
if (fromEntityId != null ? !fromEntityId.equals(that.fromEntityId) : that.fromEntityId != null) Objects.equals(toEntityId, that.toEntityId);
return false;
return toEntityId != null ? toEntityId.equals(that.toEntityId) : that.toEntityId == null;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = fromEntityId != null ? fromEntityId.hashCode() : 0; return Objects.hash(fromEntityId, toEntityId);
result = 31 * result + (toEntityId != null ? toEntityId.hashCode() : 0);
return result;
} }
@Override @Override
......
...@@ -17,25 +17,26 @@ ...@@ -17,25 +17,26 @@
*/ */
package org.apache.atlas.model.typedef; 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.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; 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 static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.NONE;
import org.codehaus.jackson.annotate.JsonIgnoreProperties; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/** /**
...@@ -279,24 +280,20 @@ public abstract class AtlasBaseTypeDef implements java.io.Serializable { ...@@ -279,24 +280,20 @@ public abstract class AtlasBaseTypeDef implements java.io.Serializable {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { return true; } if (this == o) return true;
if (o == null || getClass() != o.getClass()) { return false; } if (o == null || getClass() != o.getClass()) return false;
AtlasBaseTypeDef that = (AtlasBaseTypeDef) o; AtlasBaseTypeDef that = (AtlasBaseTypeDef) o;
if (category != null ? !category.equals(that.category) : that.category != null) { return false; } return category == that.category &&
if (guid != null ? !guid.equals(that.guid) : that.guid != null) { return false; } Objects.equals(guid, that.guid) &&
if (createdBy != null ? !createdBy.equals(that.createdBy) : that.createdBy != null) { return false; } Objects.equals(createdBy, that.createdBy) &&
if (updatedBy != null ? !updatedBy.equals(that.updatedBy) : that.updatedBy != null) { return false; } Objects.equals(updatedBy, that.updatedBy) &&
if (createTime != null ? !createTime.equals(that.createTime) : that.createTime != null) { return false; } Objects.equals(createTime, that.createTime) &&
if (updateTime != null ? !updateTime.equals(that.updateTime) : that.updateTime != null) { return false; } Objects.equals(updateTime, that.updateTime) &&
if (version != null ? !version.equals(that.version) : that.version != null) { return false; } Objects.equals(version, that.version) &&
if (name != null ? !name.equals(that.name) : that.name != null) { return false; } Objects.equals(name, that.name) &&
if (description != null ? !description.equals(that.description) : that.description != null) { return false; } Objects.equals(description, that.description) &&
if (typeVersion != null ? !typeVersion.equals(that.typeVersion) : that.typeVersion != null) { return false; } Objects.equals(typeVersion, that.typeVersion);
if (options != null ? !options.equals(that.options) : that.options != null) { return false; }
return true;
} }
......
...@@ -17,26 +17,27 @@ ...@@ -17,26 +17,27 @@
*/ */
package org.apache.atlas.model.typedef; 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.PList;
import org.apache.atlas.model.SearchFilter.SortType; import org.apache.atlas.model.SearchFilter.SortType;
import org.apache.atlas.model.TypeCategory; import org.apache.atlas.model.TypeCategory;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.codehaus.jackson.annotate.JsonAutoDetect; 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.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize; 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. * class that captures details of a classification-type.
...@@ -163,17 +164,12 @@ public class AtlasClassificationDef extends AtlasStructDef implements java.io.Se ...@@ -163,17 +164,12 @@ public class AtlasClassificationDef extends AtlasStructDef implements java.io.Se
if (!super.equals(o)) { return false; } if (!super.equals(o)) { return false; }
AtlasClassificationDef that = (AtlasClassificationDef) o; AtlasClassificationDef that = (AtlasClassificationDef) o;
return Objects.equals(superTypes, that.superTypes);
if (superTypes != null ? !superTypes.equals(that.superTypes) : that.superTypes != null) { return false; }
return true;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = super.hashCode(); return Objects.hash(super.hashCode(), superTypes);
result = 31 * result + (superTypes != null ? superTypes.hashCode() : 0);
return result;
} }
@Override @Override
......
...@@ -17,26 +17,27 @@ ...@@ -17,26 +17,27 @@
*/ */
package org.apache.atlas.model.typedef; 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.PList;
import org.apache.atlas.model.SearchFilter.SortType; import org.apache.atlas.model.SearchFilter.SortType;
import org.apache.atlas.model.TypeCategory; import org.apache.atlas.model.TypeCategory;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.codehaus.jackson.annotate.JsonAutoDetect; 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.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize; 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. * class that captures details of a entity-type.
...@@ -161,17 +162,12 @@ public class AtlasEntityDef extends AtlasStructDef implements java.io.Serializab ...@@ -161,17 +162,12 @@ public class AtlasEntityDef extends AtlasStructDef implements java.io.Serializab
if (!super.equals(o)) { return false; } if (!super.equals(o)) { return false; }
AtlasEntityDef that = (AtlasEntityDef) o; AtlasEntityDef that = (AtlasEntityDef) o;
return Objects.equals(superTypes, that.superTypes);
if (superTypes != null ? !superTypes.equals(that.superTypes) : that.superTypes != null) { return false; }
return true;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = super.hashCode(); return Objects.hash(super.hashCode(), superTypes);
result = 31 * result + (superTypes != null ? superTypes.hashCode() : 0);
return result;
} }
@Override @Override
......
...@@ -222,22 +222,17 @@ public class AtlasEnumDef extends AtlasBaseTypeDef implements Serializable { ...@@ -222,22 +222,17 @@ public class AtlasEnumDef extends AtlasBaseTypeDef implements Serializable {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { return true; } if (this == o) return true;
if (o == null || getClass() != o.getClass()) { return false; } if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) { return false; } if (!super.equals(o)) return false;
AtlasEnumDef that = (AtlasEnumDef) o; AtlasEnumDef that = (AtlasEnumDef) o;
return Objects.equals(elementDefs, that.elementDefs) &&
if (elementDefs != null ? !elementDefs.equals(that.elementDefs) : that.elementDefs != null) { return false; } Objects.equals(defaultValue, that.defaultValue);
return true;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = super.hashCode(); return Objects.hash(super.hashCode(), elementDefs, defaultValue);
result = 31 * result + (elementDefs != null ? elementDefs.hashCode() : 0);
return result;
} }
@Override @Override
...@@ -319,26 +314,17 @@ public class AtlasEnumDef extends AtlasBaseTypeDef implements Serializable { ...@@ -319,26 +314,17 @@ public class AtlasEnumDef extends AtlasBaseTypeDef implements Serializable {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { return true; } if (this == o) return true;
if (o == null || getClass() != o.getClass()) { return false; } if (o == null || getClass() != o.getClass()) return false;
AtlasEnumElementDef that = (AtlasEnumElementDef) o; AtlasEnumElementDef that = (AtlasEnumElementDef) o;
return Objects.equals(value, that.value) &&
if (value != null ? !value.equals(that.value) : that.value != null) { return false; } Objects.equals(description, that.description) &&
if (description != null ? !description.equals(that.description) : that.description != null) { Objects.equals(ordinal, that.ordinal);
return false;
}
if (ordinal != null ? !ordinal.equals(that.ordinal) : that.ordinal != null) { return false; }
return true;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = value != null ? value.hashCode() : 0; return Objects.hash(value, description, ordinal);
result = 31 * result + (description != null ? description.hashCode() : 0);
result = 31 * result + (ordinal != null ? ordinal.hashCode() : 0);
return result;
} }
@Override @Override
......
...@@ -25,6 +25,7 @@ import java.util.HashSet; ...@@ -25,6 +25,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
...@@ -224,24 +225,16 @@ public class AtlasStructDef extends AtlasBaseTypeDef implements Serializable { ...@@ -224,24 +225,16 @@ public class AtlasStructDef extends AtlasBaseTypeDef implements Serializable {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { return true; } if (this == o) return true;
if (o == null || getClass() != o.getClass()) { return false; } if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) { return false; } if (!super.equals(o)) return false;
AtlasStructDef that = (AtlasStructDef) o; AtlasStructDef that = (AtlasStructDef) o;
return Objects.equals(attributeDefs, that.attributeDefs);
if (attributeDefs != null ? !attributeDefs.equals(that.attributeDefs) : that.attributeDefs != null) {
return false;
}
return true;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = super.hashCode(); return Objects.hash(super.hashCode(), attributeDefs);
result = 31 * result + (attributeDefs != null ? attributeDefs.hashCode() : 0);
return result;
} }
@Override @Override
...@@ -433,40 +426,23 @@ public class AtlasStructDef extends AtlasBaseTypeDef implements Serializable { ...@@ -433,40 +426,23 @@ public class AtlasStructDef extends AtlasBaseTypeDef implements Serializable {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { return true; } if (this == o) return true;
if (o == null || getClass() != o.getClass()) { return false; } if (o == null || getClass() != o.getClass()) return false;
AtlasAttributeDef that = (AtlasAttributeDef) o; AtlasAttributeDef that = (AtlasAttributeDef) o;
return isOptional == that.isOptional &&
if (name != null ? !name.equals(that.name) : that.name != null) { return false; } valuesMinCount == that.valuesMinCount &&
if (typeName != null ? !typeName.equals(that.typeName) : that.typeName != null) { return false; } valuesMaxCount == that.valuesMaxCount &&
if (isOptional != that.isOptional) { return false; } isUnique == that.isUnique &&
if (cardinality != null ? !cardinality.equals(that.cardinality) : that.cardinality != null) { isIndexable == that.isIndexable &&
return false; Objects.equals(name, that.name) &&
} Objects.equals(typeName, that.typeName) &&
if (valuesMinCount != that.valuesMinCount) { return false; } cardinality == that.cardinality &&
if (valuesMaxCount != that.valuesMaxCount) { return false; } Objects.equals(constraintDefs, that.constraintDefs);
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;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = name != null ? name.hashCode() : 0; return Objects.hash(name, typeName, isOptional, cardinality, valuesMinCount, valuesMaxCount, isUnique, isIndexable, constraintDefs);
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;
} }
@Override @Override
...@@ -553,20 +529,14 @@ public class AtlasStructDef extends AtlasBaseTypeDef implements Serializable { ...@@ -553,20 +529,14 @@ public class AtlasStructDef extends AtlasBaseTypeDef implements Serializable {
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
AtlasConstraintDef that = (AtlasConstraintDef) o; AtlasConstraintDef that = (AtlasConstraintDef) o;
return Objects.equals(type, that.type) &&
if (type != null ? !type.equals(that.type) : that.type != null) return false; Objects.equals(params, that.params);
if (params != null ? !params.equals(that.params) : that.params != null) return false;
return true;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = type != null ? type.hashCode() : 0; return Objects.hash(type, params);
result = 31 * result + (params != null ? params.hashCode() : 0);
return result;
} }
@Override @Override
......
...@@ -26,6 +26,8 @@ import javax.xml.bind.annotation.XmlAccessType; ...@@ -26,6 +26,8 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement; 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.NONE;
import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY; import static org.codehaus.jackson.annotate.JsonAutoDetect.Visibility.PUBLIC_ONLY;
...@@ -101,24 +103,17 @@ public class AtlasTypeDefHeader implements java.io.Serializable { ...@@ -101,24 +103,17 @@ public class AtlasTypeDefHeader implements java.io.Serializable {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { return true; } if (this == o) return true;
if (o == null || getClass() != o.getClass()) { return false; } if (o == null || getClass() != o.getClass()) return false;
AtlasTypeDefHeader that = (AtlasTypeDefHeader) o; AtlasTypeDefHeader that = (AtlasTypeDefHeader) o;
return Objects.equals(guid, that.guid) &&
if (guid != null ? !guid.equals(that.guid) : that.guid != null) { return false; } Objects.equals(name, that.name) &&
if (name != null ? !name.equals(that.name) : that.name != null) { return false; } category == that.category;
if (category != null ? !category.equals(that.category) : that.category != null) { return false; }
return true;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = guid != null ? guid.hashCode() : 0; return Objects.hash(guid, name, category);
result = 31 * result + (name != null ? name.hashCode() : 0);
result = 31 * result + (category != null ? category.hashCode() : 0);
return result;
} }
public StringBuilder toString(StringBuilder sb) { public StringBuilder toString(StringBuilder sb) {
......
...@@ -31,6 +31,7 @@ import java.util.HashMap; ...@@ -31,6 +31,7 @@ import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Set; import java.util.Set;
/** /**
...@@ -106,25 +107,17 @@ public class EntityNotificationImpl implements EntityNotification { ...@@ -106,25 +107,17 @@ public class EntityNotificationImpl implements EntityNotification {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { if (this == o) return true;
return true; if (o == null || getClass() != o.getClass()) return false;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
EntityNotificationImpl that = (EntityNotificationImpl) o; EntityNotificationImpl that = (EntityNotificationImpl) o;
return Objects.equals(entity, that.entity) &&
return !(entity != null ? !entity.equals(that.entity) : that.entity != null) operationType == that.operationType &&
&& operationType == that.operationType && traits.equals(that.traits); Objects.equals(traits, that.traits);
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = entity != null ? entity.hashCode() : 0; return Objects.hash(entity, operationType, traits);
result = 31 * result + operationType.hashCode();
result = 31 * result + traits.hashCode();
return result;
} }
......
...@@ -26,6 +26,7 @@ import org.testng.annotations.Test; ...@@ -26,6 +26,7 @@ import org.testng.annotations.Test;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Objects;
import static org.mockito.Matchers.endsWith; import static org.mockito.Matchers.endsWith;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
...@@ -214,23 +215,16 @@ public class AbstractNotificationConsumerTest { ...@@ -214,23 +215,16 @@ public class AbstractNotificationConsumerTest {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { if (this == o) return true;
return true; if (o == null || getClass() != o.getClass()) return false;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
TestMessage that = (TestMessage) o; TestMessage that = (TestMessage) o;
return i == that.i &&
return i == that.i && (s != null ? s.equals(that.s) : that.s == null); Objects.equals(s, that.s);
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = s != null ? s.hashCode() : 0; return Objects.hash(s, i);
result = 31 * result + i;
return result;
} }
} }
......
...@@ -9,6 +9,7 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al ...@@ -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) ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ALL CHANGES: 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-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-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) ATLAS-1363 Upgrade front end maven plugin to 1.0 (sumasai)
......
...@@ -58,15 +58,7 @@ import org.codehaus.jettison.json.JSONArray; ...@@ -58,15 +58,7 @@ import org.codehaus.jettison.json.JSONArray;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.*;
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;
/** /**
* Utility class for graph operations. * Utility class for graph operations.
...@@ -607,31 +599,18 @@ public final class GraphHelper { ...@@ -607,31 +599,18 @@ public final class GraphHelper {
} }
@Override @Override
public int hashCode() { public boolean equals(Object o) {
if (this == o) return true;
final int prime = 31; if (o == null || getClass() != o.getClass()) return false;
int result = 1; VertexInfo that = (VertexInfo) o;
result = prime * result + ((guid == null) ? 0 : guid.hashCode()); return Objects.equals(guid, that.guid) &&
result = prime * result + ((vertex == null) ? 0 : vertex.hashCode()); Objects.equals(vertex, that.vertex) &&
return result; Objects.equals(typeName, that.typeName);
} }
@Override @Override
public boolean equals(Object obj) { public int hashCode() {
return Objects.hash(guid, vertex, typeName);
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;
} }
} }
......
...@@ -28,6 +28,7 @@ import org.apache.atlas.typesystem.persistence.Id; ...@@ -28,6 +28,7 @@ import org.apache.atlas.typesystem.persistence.Id;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
/** /**
* Represents a Class Instance that has not been associated with a FieldMapping. * Represents a Class Instance that has not been associated with a FieldMapping.
...@@ -158,6 +159,21 @@ public class Referenceable extends Struct implements IReferenceableInstance { ...@@ -158,6 +159,21 @@ public class Referenceable extends Struct implements IReferenceableInstance {
return systemAttributes; 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 * Matches traits, values associated with this Referenceable and skips the id match
* @param o The Referenceable which needs to be matched with * @param o The Referenceable which needs to be matched with
......
...@@ -32,6 +32,7 @@ import java.nio.charset.Charset; ...@@ -32,6 +32,7 @@ import java.nio.charset.Charset;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
...@@ -134,34 +135,18 @@ public class Id implements ITypedReferenceableInstance { ...@@ -134,34 +135,18 @@ public class Id implements ITypedReferenceableInstance {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { if (this == o) return true;
return true; if (o == null || getClass() != o.getClass()) return false;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Id id1 = (Id) o; Id id1 = (Id) o;
return version == id1.version &&
if (version != id1.version) { Objects.equals(id, id1.id) &&
return false; Objects.equals(typeName, id1.typeName) &&
} state == id1.state;
if (!typeName.equals(id1.typeName)) {
return false;
}
if (!id.equals(id1.id)) {
return false;
}
return true;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = id.hashCode(); return Objects.hash(id, typeName, version, state);
result = 31 * result + typeName.hashCode();
result = 31 * result + version;
return result;
} }
@Override @Override
......
...@@ -20,6 +20,8 @@ package org.apache.atlas.typesystem.types; ...@@ -20,6 +20,8 @@ package org.apache.atlas.typesystem.types;
import org.apache.atlas.utils.ParamChecker; import org.apache.atlas.utils.ParamChecker;
import java.util.Objects;
public final class AttributeDefinition { public final class AttributeDefinition {
public final String name; public final String name;
...@@ -55,51 +57,21 @@ public final class AttributeDefinition { ...@@ -55,51 +57,21 @@ public final class AttributeDefinition {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { if (this == o) return true;
return true; if (o == null || getClass() != o.getClass()) return false;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AttributeDefinition that = (AttributeDefinition) o; AttributeDefinition that = (AttributeDefinition) o;
return isComposite == that.isComposite &&
if (isComposite != that.isComposite) { isUnique == that.isUnique &&
return false; isIndexable == that.isIndexable &&
} Objects.equals(name, that.name) &&
if (isUnique != that.isUnique) { Objects.equals(dataTypeName, that.dataTypeName) &&
return false; Objects.equals(multiplicity, that.multiplicity) &&
} Objects.equals(reverseAttributeName, that.reverseAttributeName);
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;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = name.hashCode(); return Objects.hash(name, dataTypeName, multiplicity, isComposite, isUnique, isIndexable, reverseAttributeName);
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;
} }
@Override @Override
......
...@@ -25,6 +25,7 @@ import org.codehaus.jettison.json.JSONObject; ...@@ -25,6 +25,7 @@ import org.codehaus.jettison.json.JSONObject;
import java.io.IOException; import java.io.IOException;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Set; import java.util.Set;
public class AttributeInfo { public class AttributeInfo {
...@@ -90,40 +91,22 @@ public class AttributeInfo { ...@@ -90,40 +91,22 @@ public class AttributeInfo {
} }
@Override @Override
public boolean equals(Object o) { public int hashCode() {
if (this == o) { return Objects.hash(name, multiplicity, isComposite, isUnique, isIndexable, reverseAttributeName, dataType);
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
} }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AttributeInfo that = (AttributeInfo) o; AttributeInfo that = (AttributeInfo) o;
return isComposite == that.isComposite &&
if (isComposite != that.isComposite) { isUnique == that.isUnique &&
return false; isIndexable == that.isIndexable &&
} Objects.equals(name, that.name) &&
if (isUnique != that.isUnique) { Objects.equals(multiplicity, that.multiplicity) &&
return false; Objects.equals(reverseAttributeName, that.reverseAttributeName) &&
} Objects.equals(dataType, that.dataType);
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;
} }
public String toJson() throws JSONException { public String toJson() throws JSONException {
......
...@@ -22,6 +22,7 @@ import org.apache.atlas.utils.ParamChecker; ...@@ -22,6 +22,7 @@ import org.apache.atlas.utils.ParamChecker;
import org.apache.atlas.AtlasConstants; import org.apache.atlas.AtlasConstants;
import java.util.Arrays; import java.util.Arrays;
import java.util.Objects;
public final class EnumTypeDefinition { public final class EnumTypeDefinition {
...@@ -47,29 +48,17 @@ public final class EnumTypeDefinition { ...@@ -47,29 +48,17 @@ public final class EnumTypeDefinition {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { if (this == o) return true;
return true; if (o == null || getClass() != o.getClass()) return false;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
EnumTypeDefinition that = (EnumTypeDefinition) o; EnumTypeDefinition that = (EnumTypeDefinition) o;
return Objects.equals(name, that.name) &&
if (!Arrays.equals(enumValues, that.enumValues)) { Objects.equals(description, that.description) &&
return false; Objects.equals(version, that.version) &&
} Arrays.equals(enumValues, that.enumValues);
if (!name.equals(that.name)) {
return false;
}
return true;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = name.hashCode(); return Objects.hash(name, description, version, enumValues);
result = 31 * result + Arrays.hashCode(enumValues);
return result;
} }
} }
...@@ -18,12 +18,10 @@ ...@@ -18,12 +18,10 @@
package org.apache.atlas.typesystem.types; package org.apache.atlas.typesystem.types;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import org.apache.atlas.AtlasConstants; 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 { public class HierarchicalTypeDefinition<T extends HierarchicalType> extends StructTypeDefinition {
...@@ -61,33 +59,16 @@ public class HierarchicalTypeDefinition<T extends HierarchicalType> extends Stru ...@@ -61,33 +59,16 @@ public class HierarchicalTypeDefinition<T extends HierarchicalType> extends Stru
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { if (this == o) return true;
return true; if (o == null || getClass() != o.getClass()) return false;
} if (!super.equals(o)) return false;
if (o == null || getClass() != o.getClass()) { HierarchicalTypeDefinition<?> that = (HierarchicalTypeDefinition<?>) o;
return false; return Objects.equals(superTypes, that.superTypes) &&
} Objects.equals(hierarchicalMetaTypeName, that.hierarchicalMetaTypeName);
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;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = super.hashCode(); return Objects.hash(super.hashCode(), superTypes, hierarchicalMetaTypeName);
result = 31 * result + superTypes.hashCode();
result = 31 * result + hierarchicalMetaTypeName.hashCode();
return result;
} }
} }
...@@ -21,6 +21,8 @@ package org.apache.atlas.typesystem.types; ...@@ -21,6 +21,8 @@ package org.apache.atlas.typesystem.types;
import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject; import org.codehaus.jettison.json.JSONObject;
import java.util.Objects;
public final class Multiplicity { public final class Multiplicity {
public static final Multiplicity OPTIONAL = new Multiplicity(0, 1, false); public static final Multiplicity OPTIONAL = new Multiplicity(0, 1, false);
...@@ -52,34 +54,17 @@ public final class Multiplicity { ...@@ -52,34 +54,17 @@ public final class Multiplicity {
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { if (this == o) return true;
return true; if (o == null || getClass() != o.getClass()) return false;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Multiplicity that = (Multiplicity) o; Multiplicity that = (Multiplicity) o;
return lower == that.lower &&
if (isUnique != that.isUnique) { upper == that.upper &&
return false; isUnique == that.isUnique;
}
if (lower != that.lower) {
return false;
}
if (upper != that.upper) {
return false;
}
return true;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = lower; return Objects.hash(lower, upper, isUnique);
result = 31 * result + upper;
result = 31 * result + (isUnique ? 1 : 0);
return result;
} }
@Override @Override
......
...@@ -22,6 +22,7 @@ import org.apache.atlas.AtlasConstants; ...@@ -22,6 +22,7 @@ import org.apache.atlas.AtlasConstants;
import org.apache.atlas.utils.ParamChecker; import org.apache.atlas.utils.ParamChecker;
import java.util.Arrays; import java.util.Arrays;
import java.util.Objects;
public class StructTypeDefinition { public class StructTypeDefinition {
...@@ -65,31 +66,19 @@ public class StructTypeDefinition { ...@@ -65,31 +66,19 @@ public class StructTypeDefinition {
} }
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { if (this == o) return true;
return true; if (o == null || getClass() != o.getClass()) return false;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
StructTypeDefinition that = (StructTypeDefinition) o; StructTypeDefinition that = (StructTypeDefinition) o;
return Objects.equals(typeName, that.typeName) &&
if (!Arrays.equals(attributeDefinitions, that.attributeDefinitions)) { Objects.equals(typeDescription, that.typeDescription) &&
return false; Objects.equals(typeVersion, that.typeVersion) &&
} Arrays.equals(attributeDefinitions, that.attributeDefinitions);
if (!typeName.equals(that.typeName)) {
return false;
}
return true;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int result = typeName.hashCode(); return Objects.hash(typeName, typeDescription, typeVersion, attributeDefinitions);
result = 31 * result + Arrays.hashCode(attributeDefinitions);
return result;
} }
} }
...@@ -21,6 +21,7 @@ package org.apache.atlas.web.params; ...@@ -21,6 +21,7 @@ package org.apache.atlas.web.params;
import javax.ws.rs.WebApplicationException; import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.Objects;
/** /**
* An abstract base class from which to build Jersey parameter classes. * An abstract base class from which to build Jersey parameter classes.
...@@ -111,20 +112,16 @@ public abstract class AbstractParam<T> { ...@@ -111,20 +112,16 @@ public abstract class AbstractParam<T> {
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object o) {
if (this == obj) { if (this == o) return true;
return true; if (o == null || getClass() != o.getClass()) return false;
} AbstractParam<?> that = (AbstractParam<?>) o;
if ((obj == null) || (getClass() != obj.getClass())) { return Objects.equals(value, that.value);
return false;
}
final AbstractParam<?> that = (AbstractParam<?>) obj;
return value.equals(that.value);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return value.hashCode(); return Objects.hash(value);
} }
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment