X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fforwarding%2Fstaticrouting%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fforwarding%2Fstaticrouting%2FStaticRouteConfig.java;h=7726c0f4e78c3bc9684e0384e13da23fb1e9d9b2;hb=refs%2Fchanges%2F86%2F4286%2F7;hp=ceacebffb05cb57a8dfcc8fdf8ea8addc032e168;hpb=7c3362df780f30a47d0f6a7b7695360bbb5513bc;p=controller.git diff --git a/opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/StaticRouteConfig.java b/opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/StaticRouteConfig.java index ceacebffb0..7726c0f4e7 100644 --- a/opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/StaticRouteConfig.java +++ b/opendaylight/forwarding/staticrouting/src/main/java/org/opendaylight/controller/forwarding/staticrouting/StaticRouteConfig.java @@ -18,6 +18,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.opendaylight.controller.configuration.ConfigurationObject; import org.opendaylight.controller.sal.utils.GUIField; import org.opendaylight.controller.sal.utils.Status; import org.opendaylight.controller.sal.utils.StatusCode; @@ -25,7 +26,7 @@ import org.opendaylight.controller.sal.utils.StatusCode; /** * This class defines all the necessary configuration information for a static route. */ -public class StaticRouteConfig implements Serializable { +public class StaticRouteConfig extends ConfigurationObject implements Serializable { private static final long serialVersionUID = 1L; private static final String regexSubnet = "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." + "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." @@ -103,8 +104,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; } @@ -149,7 +151,7 @@ public class StaticRouteConfig implements Serializable { * @return SUCCESS if the config is valid */ public Status isValid() { - if ((name == null) || (name.trim().length() < 1)) { + if (!isValidResourceName(name)) { return new Status(StatusCode.BADREQUEST, "Invalid Static Route name"); } @@ -206,8 +208,9 @@ public class StaticRouteConfig implements Serializable { if (getNextHopType().equalsIgnoreCase( StaticRoute.NextHopType.SWITCHPORT.toString())) { String pieces[] = nextHop.split("/"); - if (pieces.length < 2) + if (pieces.length < 2) { return false; + } return isValidSwitchId(pieces[0]); } return false; @@ -218,8 +221,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]); @@ -337,28 +341,37 @@ public class StaticRouteConfig implements Serializable { @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; + } StaticRouteConfig other = (StaticRouteConfig) obj; if (name == null) { - if (other.name != null) + if (other.name != null) { return false; - } else if (!name.equals(other.name)) + } + } else if (!name.equals(other.name)) { return false; + } if (nextHop == null) { - if (other.nextHop != null) + if (other.nextHop != null) { return false; - } else if (!nextHop.equals(other.nextHop)) + } + } else if (!nextHop.equals(other.nextHop)) { return false; + } if (staticRoute == null) { - if (other.staticRoute != null) + if (other.staticRoute != null) { return false; - } else if (!staticRoute.equals(other.staticRoute)) + } + } else if (!staticRoute.equals(other.staticRoute)) { return false; + } return true; }