diff options
author | Henry.Sun <henry.a.sun@est.tech> | 2019-08-07 03:41:50 +0000 |
---|---|---|
committer | Henry.Sun <henry.a.sun@est.tech> | 2019-08-07 03:41:50 +0000 |
commit | b7909b8e74c0bc5920f5d0397a4371988df9e8b2 (patch) | |
tree | 3307c4c2c260c0ea975aceb6c5a5eedbb6aa5230 /models-base/src | |
parent | 52d2377853af5eb2acba40381e61de17f3fe0d29 (diff) |
replace hashCode function with compareTo
Issue-ID: POLICY-1600
Change-Id: If660cbe84424e492b6db3ab11ef97b37f046b3aa
Signed-off-by: Henry.Sun <henry.a.sun@est.tech>
Diffstat (limited to 'models-base/src')
6 files changed, 6 insertions, 6 deletions
diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java b/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java index 99b5f9710..63ab14ee5 100644 --- a/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java +++ b/models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java @@ -261,7 +261,7 @@ public class PfConceptContainer<C extends PfConcept, A extends PfNameVersion> ex return 0; } if (getClass() != otherConcept.getClass()) { - return this.hashCode() - otherConcept.hashCode(); + return getClass().getName().compareTo(otherConcept.getClass().getName()); } @SuppressWarnings("unchecked") diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java b/models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java index dfc356060..17fda7cfe 100644 --- a/models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java +++ b/models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java @@ -310,7 +310,7 @@ public class PfConceptKey extends PfKey { return 0; } if (getClass() != otherObj.getClass()) { - return this.hashCode() - otherObj.hashCode(); + return getClass().getName().compareTo(otherObj.getClass().getName()); } final PfConceptKey other = (PfConceptKey) otherObj; diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfKeyUse.java b/models-base/src/main/java/org/onap/policy/models/base/PfKeyUse.java index 836707ef2..d56b0dbab 100644 --- a/models-base/src/main/java/org/onap/policy/models/base/PfKeyUse.java +++ b/models-base/src/main/java/org/onap/policy/models/base/PfKeyUse.java @@ -152,7 +152,7 @@ public class PfKeyUse extends PfKey { return 0; } if (getClass() != otherObj.getClass()) { - return this.hashCode() - otherObj.hashCode(); + return getClass().getName().compareTo(otherObj.getClass().getName()); } final PfKeyUse other = (PfKeyUse) otherObj; diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfModel.java b/models-base/src/main/java/org/onap/policy/models/base/PfModel.java index 3dc233b02..07ec3af04 100644 --- a/models-base/src/main/java/org/onap/policy/models/base/PfModel.java +++ b/models-base/src/main/java/org/onap/policy/models/base/PfModel.java @@ -274,7 +274,7 @@ public abstract class PfModel extends PfConcept { return 0; } if (getClass() != otherObj.getClass()) { - return this.hashCode() - otherObj.hashCode(); + return getClass().getName().compareTo(otherObj.getClass().getName()); } final PfModel other = (PfModel) otherObj; diff --git a/models-base/src/main/java/org/onap/policy/models/base/PfReferenceKey.java b/models-base/src/main/java/org/onap/policy/models/base/PfReferenceKey.java index bda5aed12..bdf16dcdf 100644 --- a/models-base/src/main/java/org/onap/policy/models/base/PfReferenceKey.java +++ b/models-base/src/main/java/org/onap/policy/models/base/PfReferenceKey.java @@ -405,7 +405,7 @@ public class PfReferenceKey extends PfKey { return 0; } if (getClass() != otherObj.getClass()) { - return this.hashCode() - otherObj.hashCode(); + return getClass().getName().compareTo(otherObj.getClass().getName()); } final PfReferenceKey other = (PfReferenceKey) otherObj; diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfKeyTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfKeyTest.java index 9ef1aeb75..fca73b0d6 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/PfKeyTest.java +++ b/models-base/src/test/java/org/onap/policy/models/base/PfKeyTest.java @@ -136,7 +136,7 @@ public class PfKeyTest { .hasMessage("otherObj is marked @NonNull but is null"); assertEquals(0, someKey0.compareTo(someKey0)); - assertEquals(266127751, someKey0.compareTo(new DummyPfKey())); + assertEquals(-36, someKey0.compareTo(new DummyPfKey())); assertFalse(someKey0.equals(null)); assertTrue(someKey0.equals(someKey0)); |