replace hashCode function with compareTo 48/92848/1
authorHenry.Sun <henry.a.sun@est.tech>
Wed, 7 Aug 2019 03:41:50 +0000 (03:41 +0000)
committerHenry.Sun <henry.a.sun@est.tech>
Wed, 7 Aug 2019 03:41:50 +0000 (03:41 +0000)
Issue-ID: POLICY-1600
Change-Id: If660cbe84424e492b6db3ab11ef97b37f046b3aa
Signed-off-by: Henry.Sun <henry.a.sun@est.tech>
21 files changed:
models-base/src/main/java/org/onap/policy/models/base/PfConceptContainer.java
models-base/src/main/java/org/onap/policy/models/base/PfConceptKey.java
models-base/src/main/java/org/onap/policy/models/base/PfKeyUse.java
models-base/src/main/java/org/onap/policy/models/base/PfModel.java
models-base/src/main/java/org/onap/policy/models/base/PfReferenceKey.java
models-base/src/test/java/org/onap/policy/models/base/PfKeyTest.java
models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdp.java
models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogical.java
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintValidValues.java
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaDataType.java
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEntityType.java
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaEventFilter.java
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaModel.java
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyType.java
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaProperty.java
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaServiceTemplate.java
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTimeInterval.java
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTopologyTemplate.java
models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTrigger.java

index 99b5f97..63ab14e 100644 (file)
@@ -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")
index dfc3560..17fda7c 100644 (file)
@@ -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;
index 836707e..d56b0db 100644 (file)
@@ -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;
index 3dc233b..07ec3af 100644 (file)
@@ -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;
index bda5aed..bdf16dc 100644 (file)
@@ -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;
index 9ef1aeb..fca73b0 100644 (file)
@@ -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));
index 528d6fb..7d90c03 100644 (file)
@@ -210,7 +210,7 @@ public class JpaPdp extends PfConcept implements PfAuthorative<Pdp>, Serializabl
             return 0;
         }
         if (getClass() != otherConcept.getClass()) {
-            return this.hashCode() - otherConcept.hashCode();
+            return getClass().getName().compareTo(otherConcept.getClass().getName());
         }
 
         final JpaPdp other = (JpaPdp) otherConcept;
index f0ff4a6..723d427 100644 (file)
@@ -360,7 +360,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro
             return 0;
         }
         if (getClass() != otherConcept.getClass()) {
-            return this.hashCode() - otherConcept.hashCode();
+            return getClass().getName().compareTo(otherConcept.getClass().getName());
         }
 
         final JpaPdpSubGroup other = (JpaPdpSubGroup) otherConcept;
index 632f84a..41cd1c2 100644 (file)
@@ -140,7 +140,7 @@ public class JpaToscaConstraintLogical extends JpaToscaConstraint {
             return 0;
         }
         if (getClass() != otherConstraint.getClass()) {
-            return this.hashCode() - otherConstraint.hashCode();
+            return getClass().getName().compareTo(otherConstraint.getClass().getName());
         }
 
         final JpaToscaConstraintLogical other = (JpaToscaConstraintLogical) otherConstraint;
index 248ca49..2a12157 100644 (file)
@@ -92,7 +92,7 @@ public class JpaToscaConstraintValidValues extends JpaToscaConstraint {
             return 0;
         }
         if (getClass() != otherConstraint.getClass()) {
-            return this.hashCode() - otherConstraint.hashCode();
+            return getClass().getName().compareTo(otherConstraint.getClass().getName());
         }
 
         final JpaToscaConstraintValidValues other = (JpaToscaConstraintValidValues) otherConstraint;
index cf1150a..7e2b641 100644 (file)
@@ -244,7 +244,7 @@ public class JpaToscaDataType extends JpaToscaEntityType<ToscaDataType> implemen
             return 0;
         }
         if (getClass() != otherConcept.getClass()) {
-            return this.hashCode() - otherConcept.hashCode();
+            return getClass().getName().compareTo(otherConcept.getClass().getName());
         }
 
         final JpaToscaDataType other = (JpaToscaDataType) otherConcept;
index a39515b..bade7a2 100644 (file)
@@ -248,7 +248,7 @@ public class JpaToscaEntityType<T extends ToscaEntity> extends PfConcept impleme
             return 0;
         }
         if (getClass() != otherConcept.getClass()) {
-            return this.hashCode() - otherConcept.hashCode();
+            return getClass().getName().compareTo(otherConcept.getClass().getName());
         }
 
         @SuppressWarnings("unchecked")
index 3907a1b..40727c9 100644 (file)
@@ -161,7 +161,7 @@ public class JpaToscaEventFilter extends PfConcept {
             return 0;
         }
         if (getClass() != otherConcept.getClass()) {
-            return this.hashCode() - otherConcept.hashCode();
+            return getClass().getName().compareTo(otherConcept.getClass().getName());
         }
 
         final JpaToscaEventFilter other = (JpaToscaEventFilter) otherConcept;
index 204ef5b..5e4bd4f 100644 (file)
@@ -137,7 +137,7 @@ public class JpaToscaModel extends PfModel {
         }
 
         if (getClass() != otherConcept.getClass()) {
-            return this.hashCode() - otherConcept.hashCode();
+            return getClass().getName().compareTo(otherConcept.getClass().getName());
         }
 
         final JpaToscaModel other = (JpaToscaModel) otherConcept;
index 30ad2b2..7b4ffd1 100644 (file)
@@ -331,7 +331,7 @@ public class JpaToscaPolicy extends JpaToscaEntityType<ToscaPolicy> implements P
         }
 
         if (getClass() != otherConcept.getClass()) {
-            return this.hashCode() - otherConcept.hashCode();
+            return getClass().getName().compareTo(otherConcept.getClass().getName());
         }
 
         final JpaToscaPolicy other = (JpaToscaPolicy) otherConcept;
index a6bc835..d7560c4 100644 (file)
@@ -280,7 +280,7 @@ public class JpaToscaPolicyType extends JpaToscaEntityType<ToscaPolicyType> impl
             return 0;
         }
         if (getClass() != otherConcept.getClass()) {
-            return this.hashCode() - otherConcept.hashCode();
+            return getClass().getName().compareTo(otherConcept.getClass().getName());
         }
 
         final JpaToscaPolicyType other = (JpaToscaPolicyType) otherConcept;
index e2b6e6f..10e8b5d 100644 (file)
@@ -286,7 +286,7 @@ public class JpaToscaProperty extends PfConcept implements PfAuthorative<ToscaPr
             return 0;
         }
         if (getClass() != otherConcept.getClass()) {
-            return this.hashCode() - otherConcept.hashCode();
+            return getClass().getName().compareTo(otherConcept.getClass().getName());
         }
 
         final JpaToscaProperty other = (JpaToscaProperty) otherConcept;
index f9e388b..904db84 100644 (file)
@@ -250,7 +250,7 @@ public class JpaToscaServiceTemplate extends JpaToscaEntityType<ToscaServiceTemp
             return 0;
         }
         if (getClass() != otherConcept.getClass()) {
-            return this.hashCode() - otherConcept.hashCode();
+            return getClass().getName().compareTo(otherConcept.getClass().getName());
         }
 
         final JpaToscaServiceTemplate other = (JpaToscaServiceTemplate) otherConcept;
index 369aa03..a62affd 100644 (file)
@@ -157,7 +157,7 @@ public class JpaToscaTimeInterval extends PfConcept {
             return 0;
         }
         if (getClass() != otherConcept.getClass()) {
-            return this.hashCode() - otherConcept.hashCode();
+            return getClass().getName().compareTo(otherConcept.getClass().getName());
         }
 
         final JpaToscaTimeInterval other = (JpaToscaTimeInterval) otherConcept;
index b1c3f20..bafcb84 100644 (file)
@@ -185,7 +185,7 @@ public class JpaToscaTopologyTemplate extends PfConcept implements PfAuthorative
             return 0;
         }
         if (getClass() != otherConcept.getClass()) {
-            return this.hashCode() - otherConcept.hashCode();
+            return getClass().getName().compareTo(otherConcept.getClass().getName());
         }
 
         final JpaToscaTopologyTemplate other = (JpaToscaTopologyTemplate) otherConcept;
index 551dbe5..f46d43a 100644 (file)
@@ -234,7 +234,7 @@ public class JpaToscaTrigger extends PfConcept {
             return 0;
         }
         if (getClass() != otherConcept.getClass()) {
-            return this.hashCode() - otherConcept.hashCode();
+            return getClass().getName().compareTo(otherConcept.getClass().getName());
         }
 
         final JpaToscaTrigger other = (JpaToscaTrigger) otherConcept;