Changes for Checkstyle 8.32
[policy/models.git] / models-base / src / main / java / org / onap / policy / models / base / PfModel.java
index 3dc233b..340f4e3 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation.
+ *  Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,17 +24,14 @@ package org.onap.policy.models.base;
 import java.util.List;
 import java.util.Set;
 import java.util.TreeSet;
-
 import javax.persistence.EmbeddedId;
 import javax.persistence.Entity;
 import javax.persistence.Inheritance;
 import javax.persistence.InheritanceType;
 import javax.persistence.Table;
-
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.NonNull;
-
 import org.onap.policy.common.utils.validation.Assertions;
 import org.onap.policy.models.base.PfValidationResult.ValidationResult;
 
@@ -91,6 +89,7 @@ public abstract class PfModel extends PfConcept {
      */
     public PfModel(@NonNull final PfModel copyConcept) {
         super(copyConcept);
+        this.key = new PfConceptKey(copyConcept.key);
     }
 
     /**
@@ -132,9 +131,8 @@ public abstract class PfModel extends PfConcept {
                 result = validateArtifactKeyInModel((PfConceptKey) pfKey, artifactKeySet, result);
             } else if (pfKey instanceof PfReferenceKey) {
                 result = validateReferenceKeyInModel((PfReferenceKey) pfKey, referenceKeySet, result);
-            }
-            // It must be a PfKeyUse, nothing else is legal
-            else {
+            } else {
+                // It must be a PfKeyUse, nothing else is legal
                 usedKeySet.add((PfKeyUse) pfKey);
             }
         }
@@ -274,21 +272,11 @@ 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;
 
         return key.compareTo(other.key);
     }
-
-    @Override
-    public PfConcept copyTo(@NonNull final PfConcept target) {
-        Assertions.instanceOf(target, PfModel.class);
-
-        final PfModel copy = ((PfModel) target);
-        copy.setKey(new PfConceptKey(key));
-
-        return copy;
-    }
 }