Merge "Fix sonar code coverage for BridgeConfigurationManagerImpl.java"
[netvirt.git] / openstack / net-virt / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / SouthboundEvent.java
index ac7b6a13e7ab58ccd6acf77b2a9b2796f71ec83d..b2c47e14d4e6f81b2014f9629784e8c1cb31005d 100644 (file)
@@ -11,36 +11,32 @@ package org.opendaylight.ovsdb.openstack.netvirt;
 
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.ovsdb.lib.notation.Row;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
 
-public class SouthboundEvent {
-    public enum Type { NODE, ROW };
-    public enum Action { ADD, UPDATE, DELETE };
+public class SouthboundEvent extends AbstractEvent {
+    public enum Type { NODE, ROW }
     private Type type;
-    private Action action;
     private Node node;
     private String tableName;
     private String uuid;
     private Row row;
     private Object context;
     public SouthboundEvent(Node node, Action action) {
-        super();
+        super(HandlerType.SOUTHBOUND, action);
         this.type = Type.NODE;
-        this.action = action;
         this.node = node;
     }
     public SouthboundEvent(Node node, String tableName, String uuid, Row row, Action action) {
-        super();
+        super(HandlerType.SOUTHBOUND, action);
         this.type = Type.ROW;
-        this.action = action;
         this.node = node;
         this.tableName = tableName;
         this.uuid = uuid;
         this.row = row;
     }
     public SouthboundEvent(Node node, String tableName, String uuid, Row row, Object context, Action action) {
-        super();
+        super(HandlerType.SOUTHBOUND, action);
         this.type = Type.ROW;
-        this.action = action;
         this.node = node;
         this.tableName = tableName;
         this.uuid = uuid;
@@ -50,9 +46,6 @@ public class SouthboundEvent {
     public Type getType() {
         return type;
     }
-    public Action getAction() {
-        return action;
-    }
     public Node getNode() {
         return node;
     }
@@ -70,14 +63,13 @@ public class SouthboundEvent {
     }
     @Override
     public String toString() {
-        return "SouthboundEvent [type=" + type + ", action=" + action + ", node=" + node + ", tableName=" + tableName
+        return "SouthboundEvent [type=" + type + ", action=" + super.getAction() + ", node=" + node + ", tableName=" + tableName
                 + ", uuid=" + uuid + ", row=" + row + ", context=" + context.toString() + "]";
     }
     @Override
     public int hashCode() {
         final int prime = 31;
-        int result = 1;
-        result = prime * result + ((action == null) ? 0 : action.hashCode());
+        int result = super.hashCode();
         result = prime * result + ((node == null) ? 0 : node.hashCode());
         result = prime * result + ((tableName == null) ? 0 : tableName.hashCode());
         result = prime * result + ((type == null) ? 0 : type.hashCode());
@@ -86,32 +78,47 @@ public class SouthboundEvent {
     }
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
-        SouthboundEvent other = (SouthboundEvent) obj;
-        if (action != other.action)
+        }
+        if (!super.equals(obj)) {
             return false;
+        }
+        SouthboundEvent other = (SouthboundEvent) obj;
         if (node == null) {
-            if (other.node != null)
+            if (other.node != null) {
                 return false;
-        } else if (!node.equals(other.node))
+            }
+        } else if (!node.equals(other.node)) {
             return false;
+        }
         if (tableName == null) {
-            if (other.tableName != null)
+            if (other.tableName != null) {
                 return false;
-        } else if (!tableName.equals(other.tableName))
+            }
+        } else if (!tableName.equals(other.tableName)) {
             return false;
-        if (type != other.type)
+        }
+        if (type == null) {
+            if (other.type != null) {
+                return false;
+            }
+        } else if (!type.equals(other.type)) {
             return false;
+        }
         if (uuid == null) {
-            if (other.uuid != null)
+            if (other.uuid != null) {
                 return false;
-        } else if (!uuid.equals(other.uuid))
+            }
+        } else if (!uuid.equals(other.uuid)) {
             return false;
+        }
         return true;
     }
 }