Merge "Reorder modifiers"
[so.git] / mso-catalog-db / src / main / java / org / openecomp / mso / db / catalog / beans / HeatNestedTemplate.java
index 5bdf21b..1fff176 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * OPENECOMP - MSO
+ * ONAP - SO
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
@@ -23,11 +23,15 @@ package org.openecomp.mso.db.catalog.beans;
 
 import java.io.Serializable;
 
+import com.openpojo.business.annotation.BusinessKey;
+
 public class HeatNestedTemplate implements Serializable {
 
-    private String parentTemplateId;
-    private String childTemplateId;
-    private String providerResourceFile;
+       @BusinessKey
+    private String parentTemplateId = null;
+       @BusinessKey
+    private String childTemplateId = null;
+    private String providerResourceFile = null;
     public static final long serialVersionUID = -1322322139926390329L;
 
     public HeatNestedTemplate () {
@@ -61,12 +65,12 @@ public class HeatNestedTemplate implements Serializable {
     @Override
     public String toString () {
         StringBuilder sb = new StringBuilder ();
-        sb.append ("ParentTemplateId=" + this.parentTemplateId);
-        sb.append (", ChildTemplateId=" + this.childTemplateId);
+        sb.append("ParentTemplateId=").append(this.parentTemplateId);
+        sb.append(", ChildTemplateId=").append(this.childTemplateId);
         if (this.providerResourceFile == null) {
             sb.append (", providerResourceFile=null");
         } else {
-            sb.append (",providerResourceFile=" + this.providerResourceFile);
+            sb.append(",providerResourceFile=").append(this.providerResourceFile);
         }
         return sb.toString ();
     }
@@ -90,8 +94,16 @@ public class HeatNestedTemplate implements Serializable {
     public int hashCode () {
         // hash code does not have to be a unique result - only that two objects that should be treated as equal
         // return the same value. so this should work.
-        int result = 0;
-        result = this.parentTemplateId.hashCode() + this.childTemplateId.hashCode();
+        int result;
+        int parentTemplateIdHash = 0;
+        int childTemplateIdHash = 0;
+        if (this.parentTemplateId != null) {
+               parentTemplateIdHash = this.parentTemplateId.hashCode();
+        }
+        if (this.childTemplateId != null) {
+               childTemplateIdHash = this.childTemplateId.hashCode();
+        }
+        result = parentTemplateIdHash + childTemplateIdHash;
         return result;
     }
 }