Prediction Template Instance Duplication Validation

Change-Id: I0c5a2eda14d2c3cac620e60d3561490b46a3f389
diff --git a/apps/aiplugin/api/src/main/java/org/onosproject/aiplugin/PredictionTemplate.java b/apps/aiplugin/api/src/main/java/org/onosproject/aiplugin/PredictionTemplate.java
index 493fe4a..e98c03f 100644
--- a/apps/aiplugin/api/src/main/java/org/onosproject/aiplugin/PredictionTemplate.java
+++ b/apps/aiplugin/api/src/main/java/org/onosproject/aiplugin/PredictionTemplate.java
@@ -21,6 +21,7 @@
 import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Preconditions;
+import java.util.Objects;
 
 /**
  * Class representing a prediction template.
@@ -126,6 +127,56 @@
     }
 
     /**
+     * Compares this prediction template to the specified object. The result is true if and only if
+     * the argument is not null and is a PredictionTemplate object that represents the same template
+     * as this object.
+     *
+     * @param obj The object to compare this prediction template against.
+     * @return True if the given object represents a PredictionTemplate equivalent to this template.
+     * False otherwise.
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        PredictionTemplate other = (PredictionTemplate) obj;
+        return Objects.equals(templateVersion, other.templateVersion) &&
+                Objects.equals(id, other.id) &&
+                Objects.equals(type, other.type) &&
+                Objects.equals(datasource, other.datasource) &&
+                Objects.equals(selector, other.selector) &&
+                Objects.equals(group, other.group) &&
+                Objects.equals(sort, other.sort) &&
+                Objects.equals(condition, other.condition);
+    }
+
+    /**
+     * Returns a hash code value for the prediction template.
+     *
+     * @return A hash code value for this prediction template.
+     */
+    @Override
+    public int hashCode() {
+        int result = 59;
+        result = result * 59 + (templateVersion != null ? templateVersion.hashCode() : 0);
+        result = result * 59 + (id != null ? id.hashCode() : 0);
+        result = result * 59 + (type != null ? type.hashCode() : 0);
+        result = result * 59 + (datasource != null ? datasource.hashCode() : 0);
+        result = result * 59 + (selector != null ? selector.hashCode() : 0);
+        result = result * 59 + (group != null ? group.hashCode() : 0);
+        result = result * 59 + (sort != null ? sort.hashCode() : 0);
+        result = result * 59 + (condition != null ? condition.hashCode() : 0);
+        return result;
+    }
+
+    /**
      * Static method to create a new Builder instance.
      *
      * @return A new Builder for creating a PredictionTemplate instance.