X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=blobdiff_plain;f=ONAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Frest%2Fjpa%2FPolicyEntity.java;h=c262aec4ea7cc0c5bf2f1557420fa8808d8707d2;hp=4cb4440c17d6023759c425ff781676fd327d1eec;hb=401b48bc573561f097960a9ca7abe6d788456f28;hpb=073cc188efe9abb4c010cf674e34e2cf46ef1c52 diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEntity.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEntity.java index 4cb4440c1..c262aec4e 100644 --- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEntity.java +++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/PolicyEntity.java @@ -23,6 +23,7 @@ package org.onap.policy.rest.jpa; */ import java.io.Serializable; import java.util.Date; +import java.util.Objects; import javax.persistence.Column; import javax.persistence.Entity; @@ -136,21 +137,6 @@ public class PolicyEntity implements Serializable { public void preUpdate() { this.modifiedDate = new Date(); } - - /* - public void resetPolicyVersion(){ - this.policyVersion = 1; - } - public void advancePolicyVersion(){ - this.policyVersion++; - } - public int getPolicyVersion(){ - return this.policyVersion; - } - public void setPolicyVersion(int polVer){ - this.policyVersion = polVer; - } - */ /** * @return the policyId @@ -303,6 +289,42 @@ public class PolicyEntity implements Serializable { public void setDeleted(boolean deleted) { this.deleted = deleted; } + + @Override + public int hashCode() { + return Objects.hash(policyId, policyName, scope, version, policyVersion, policyData, configurationDataEntity, + actionBodyEntity, createdBy, createdDate, description, modifiedBy, modifiedDate, deleted); + } + + @Override + public boolean equals(Object obj) { + if(obj == null){ + return false; + } + if(obj == this){ + return true; + } + if(!(obj instanceof PolicyEntity)){ + return false; + } + + PolicyEntity p = (PolicyEntity) obj; + + return policyId == p.policyId && + policyName.equals(p.policyName) && + scope.equals(p.scope) && + version == p.version && + policyVersion == p.policyVersion && + policyData.equals(p.policyData) && + ((configurationDataEntity == null && p.configurationDataEntity == null) || (configurationDataEntity!=null && configurationDataEntity.equals(p.configurationDataEntity))) && + ((actionBodyEntity == null && p.actionBodyEntity == null) || (actionBodyEntity!=null && actionBodyEntity.equals(p.actionBodyEntity))) && + createdBy.equals(p.createdBy) && + createdDate.equals(p.createdDate) && + description.equals(p.description) && + modifiedBy.equals(p.modifiedBy) && + modifiedDate.equals(p.modifiedDate) && + deleted == p.deleted; + } }