aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java/org
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2019-03-06 14:25:02 +0200
committerIttay Stern <ittay.stern@att.com>2019-03-06 17:54:56 +0200
commit54aad7deb7a02ecca4bc7ed4d7913ccd59eb3bf9 (patch)
tree84250549f1d7e91234a41960866098d5d147ebbf /vid-app-common/src/main/java/org
parent7c64fbbaff5985acb3a6aea977c5c15b4f2f59e1 (diff)
Fix cyclic CategoryParameterOption::hashCode
Issue-ID: VID-430 Change-Id: Ib49b71726fe508f1ec9bfe8c60836af1c5ca786b Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-app-common/src/main/java/org')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java40
1 files changed, 31 insertions, 9 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java b/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java
index 237747933..70f7b5aa2 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/CategoryParameterOption.java
@@ -20,12 +20,19 @@
package org.onap.vid.model;
-import org.onap.portalsdk.core.domain.support.DomainVo;
-
-import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.Set;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import org.onap.portalsdk.core.domain.support.DomainVo;
@Entity
@Table(name = "vid_category_parameter_option")
@@ -124,24 +131,39 @@ public class CategoryParameterOption extends DomainVo {
@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;
+ }
CategoryParameterOption that = (CategoryParameterOption) o;
- if (getAppId() != null ? !getAppId().equals(that.getAppId()) : that.getAppId() != null) return false;
- if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) return false;
- return getCategoryParameter() != null ? getCategoryParameter().equals(that.getCategoryParameter()) : that.getCategoryParameter() == null;
+ if (getAppId() != null ? !getAppId().equals(that.getAppId()) : that.getAppId() != null) {
+ return false;
+ }
+ if (getName() != null ? !getName().equals(that.getName()) : that.getName() != null) {
+ return false;
+ }
+ return getCategoryParameter() != null ? getCategoryParameter().equals(that.getCategoryParameter())
+ : that.getCategoryParameter() == null;
}
@Override
public int hashCode() {
int result = getAppId() != null ? getAppId().hashCode() : 0;
result = 31 * result + (getName() != null ? getName().hashCode() : 0);
- result = 31 * result + (getCategoryParameter() != null ? getCategoryParameter().hashCode() : 0);
+ result = 31 * result + hashCodeOfParentCategoryParameter();
return result;
}
+ private int hashCodeOfParentCategoryParameter() {
+ // Don't use getCategoryParameter's hashCode, as it might loop back to self's hasCode
+ return (getCategoryParameter() == null || getCategoryParameter().getId() == null)
+ ? 0 : getCategoryParameter().getId().hashCode();
+ }
+
@Override
public String toString() {
return "CategoryParameterOption{" +