Fix sonar violations
[aai/gizmo.git] / src / main / java / org / onap / crud / event / GraphEvent.java
index 63b84fd..b189373 100644 (file)
  */
 package org.onap.crud.event;
 
+import java.util.Objects;
+import javax.ws.rs.core.Response.Status;
+import org.onap.crud.exception.CrudException;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import com.google.gson.annotations.SerializedName;
 
-import org.onap.crud.exception.CrudException;
-
-import javax.ws.rs.core.Response.Status;
-
 public class GraphEvent {
 
   public enum GraphEventOperation {
@@ -171,10 +170,32 @@ public class GraphEvent {
 
   @Override
   public String toString() {
-
     return toJson();
   }
 
+  @Override
+  public boolean equals(Object o){
+    if(o == this){
+      return true;
+    }
+
+    if( !(o instanceof GraphEvent)){
+      return false;
+    }
+
+    GraphEvent graphEvent = (GraphEvent) o;
+    return this.dbTransactionId.equals(
+        graphEvent.getDbTransactionId())
+        && this.timestamp == graphEvent.getTimestamp()
+        && this.operation.equals(graphEvent.getOperation()
+    );
+  }
+
+  @Override
+  public int hashCode() {
+    return Objects.hash(this.dbTransactionId, this.timestamp, this.operation);
+  }
+
   public String getObjectKey() {
     if (this.getVertex() != null) {
       return this.getVertex().getId();