From b7909b8e74c0bc5920f5d0397a4371988df9e8b2 Mon Sep 17 00:00:00 2001 From: "Henry.Sun" Date: Wed, 7 Aug 2019 03:41:50 +0000 Subject: replace hashCode function with compareTo Issue-ID: POLICY-1600 Change-Id: If660cbe84424e492b6db3ab11ef97b37f046b3aa Signed-off-by: Henry.Sun --- .../src/main/java/org/onap/policy/models/base/PfConceptContainer.java | 2 +- models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java | 2 +- models-base/src/main/java/org/onap/policy/models/base/PfKeyUse.java | 2 +- models-base/src/main/java/org/onap/policy/models/base/PfModel.java | 2 +- .../src/main/java/org/onap/policy/models/base/PfReferenceKey.java | 2 +- models-base/src/test/java/org/onap/policy/models/base/PfKeyTest.java | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'models-base') 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 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)); -- cgit 1.2.3-korg