Fix sonar violations
[aai/gizmo.git] / src / main / java / org / onap / crud / event / GraphEvent.java
index 3cfcd8e..b189373 100644 (file)
@@ -1,16 +1,15 @@
 /**
  * ============LICENSE_START=======================================================
- * Gizmo
+ * org.onap.aai
  * ================================================================================
- * Copyright © 2017 AT&T Intellectual Property.
- * Copyright © 2017 Amdocs
- * All rights reserved.
+ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2017-2018 Amdocs
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *    http://www.apache.org/licenses/LICENSE-2.0
+ *       http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * ============LICENSE_END=========================================================
- *
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  */
 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 {
@@ -174,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();