Merge "Bug 499: Added support for old DOM Broker APIs."
[controller.git] / opendaylight / sal / api / src / main / java / org / opendaylight / controller / sal / core / Edge.java
index 162a4d4232eef7e06b4b9162faab1cc1140b54aa..0dffee9c474de57797117a218f4aa019e6a33e85 100644 (file)
 package org.opendaylight.controller.sal.core;
 
 import java.io.Serializable;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.EqualsBuilder;
 
-import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
 
 /**
  *
@@ -46,6 +44,7 @@ public class Edge implements Serializable {
     /**
      * Private constructor used for JAXB mapping
      */
+    @SuppressWarnings("unused")
     private Edge() {
         this.tailNodeConnector = null;
         this.headNodeConnector = null;
@@ -86,6 +85,19 @@ public class Edge implements Serializable {
         }
     }
 
+    /**
+     * Create the reversed edge
+     * @return The reversed edge.
+     */
+    public Edge reverse() {
+        Edge re;
+        try {
+            re = new Edge(this.headNodeConnector, this.tailNodeConnector);
+        } catch (ConstructionException e) {
+            re = null;
+        }
+        return re;
+    }
     /**
      * getter of edge
      *
@@ -126,12 +138,39 @@ public class Edge implements Serializable {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime
+                * result
+                + ((headNodeConnector == null) ? 0 : headNodeConnector
+                        .hashCode());
+        result = prime
+                * result
+                + ((tailNodeConnector == null) ? 0 : tailNodeConnector
+                        .hashCode());
+        return result;
     }
 
     @Override
     public boolean equals(Object obj) {
-        return EqualsBuilder.reflectionEquals(this, obj);
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        Edge other = (Edge) obj;
+        if (headNodeConnector == null) {
+            if (other.headNodeConnector != null)
+                return false;
+        } else if (!headNodeConnector.equals(other.headNodeConnector))
+            return false;
+        if (tailNodeConnector == null) {
+            if (other.tailNodeConnector != null)
+                return false;
+        } else if (!tailNodeConnector.equals(other.tailNodeConnector))
+            return false;
+        return true;
     }
 
     @Override