Update context-instance xpath format according to latest changes in config-api yang.
[controller.git] / opendaylight / forwarding / staticrouting / src / main / java / org / opendaylight / controller / forwarding / staticrouting / StaticRouteConfig.java
index 706c29e9cb7043d5729c404196a259213e0fecbf..a4505c8b1c8e6a732127de0aebbb4746874aacee 100644 (file)
@@ -18,8 +18,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.opendaylight.controller.sal.utils.GUIField;
 import org.opendaylight.controller.sal.utils.Status;
 import org.opendaylight.controller.sal.utils.StatusCode;
@@ -105,8 +103,9 @@ public class StaticRouteConfig implements Serializable {
      * @return The string representation of the next hop address type
      */
     public String getNextHopType() {
-        if (nextHopType == null)
+        if (nextHopType == null) {
             return StaticRoute.NextHopType.IPADDRESS.toString();
+        }
         return nextHopType;
     }
 
@@ -153,18 +152,18 @@ public class StaticRouteConfig implements Serializable {
     public Status isValid() {
         if ((name == null) || (name.trim().length() < 1)) {
             return new Status(StatusCode.BADREQUEST,
-                       "Invalid Static Route name");
+                        "Invalid Static Route name");
         }
         if (!isValidStaticRouteEntry()) {
             return new Status(StatusCode.BADREQUEST,
-                       "Invalid Static Route entry. Please use the " +
-                       "IPAddress/mask format. Default gateway " +
-                       "(0.0.0.0/0) is NOT supported.");
+                        "Invalid Static Route entry. Please use the " +
+                        "IPAddress/mask format. Default gateway " +
+                        "(0.0.0.0/0) is NOT supported.");
         }
         if (!isValidNextHop()) {
             return new Status(StatusCode.BADREQUEST,
-                       "Invalid NextHop IP Address configuration. " +
-                                       "Please use the X.X.X.X format.");
+                        "Invalid NextHop IP Address configuration. " +
+                                        "Please use the X.X.X.X format.");
         }
 
         return new Status(StatusCode.SUCCESS, null);
@@ -220,8 +219,9 @@ public class StaticRouteConfig implements Serializable {
      * @return The IP address
      */
     public InetAddress getStaticRouteIP() {
-        if (!isValidStaticRouteEntry())
+        if (!isValidStaticRouteEntry()) {
             return null;
+        }
         InetAddress ip = null;
         try {
             ip = InetAddress.getByName(staticRoute.split("/")[0]);
@@ -328,12 +328,43 @@ public class StaticRouteConfig implements Serializable {
 
     @Override
     public int hashCode() {
-        return HashCodeBuilder.reflectionHashCode(this);
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((nextHop == null) ? 0 : nextHop.hashCode());
+        result = prime * result
+                + ((staticRoute == null) ? 0 : staticRoute.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;
+        }
+        StaticRouteConfig other = (StaticRouteConfig) obj;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if (nextHop == null) {
+            if (other.nextHop != null)
+                return false;
+        } else if (!nextHop.equals(other.nextHop))
+            return false;
+        if (staticRoute == null) {
+            if (other.staticRoute != null)
+                return false;
+        } else if (!staticRoute.equals(other.staticRoute))
+            return false;
+        return true;
     }
 
     @Override