aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main/java
diff options
context:
space:
mode:
authorWojciech Sliwka <wojciech.sliwka@nokia.com>2019-03-07 06:58:05 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-07 06:58:05 +0000
commit31995f01d6de1b1df368d68806e137a3aca56831 (patch)
tree4a3a6594f0a835f5f4d41941e44d1bd69719434f /vid-app-common/src/main/java
parent448b65dde75f4c31138dc32ff570a05946ff43e3 (diff)
parent54aad7deb7a02ecca4bc7ed4d7913ccd59eb3bf9 (diff)
Merge "Fix cyclic CategoryParameterOption::hashCode"
Diffstat (limited to 'vid-app-common/src/main/java')
-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{" +