X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Ftopologymanager%2Fimplementation%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Ftopologymanager%2FTopologyUserLinkConfig.java;h=3532ab78e0f10b2c4b4f428abc7b234c136b9b78;hp=1b1e6f49d153d3b57ccfeb8e120bf2c3d6c7581d;hb=405ea7ce68d22bd3d2501857c5253793b581b086;hpb=23587828159739bdfd026d8f3f493b1d59575dbb diff --git a/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/TopologyUserLinkConfig.java b/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/TopologyUserLinkConfig.java index 1b1e6f49d1..3532ab78e0 100644 --- a/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/TopologyUserLinkConfig.java +++ b/opendaylight/topologymanager/implementation/src/main/java/org/opendaylight/controller/topologymanager/TopologyUserLinkConfig.java @@ -16,6 +16,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import org.opendaylight.controller.configuration.ConfigurationObject; import org.opendaylight.controller.sal.core.NodeConnector; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,7 +26,7 @@ import org.slf4j.LoggerFactory; */ @XmlRootElement @XmlAccessorType(XmlAccessType.NONE) -public class TopologyUserLinkConfig implements Serializable { +public class TopologyUserLinkConfig extends ConfigurationObject implements Serializable { private static final long serialVersionUID = 1L; private static final Logger logger = LoggerFactory.getLogger(TopologyUserLinkConfig.class); @@ -38,19 +39,24 @@ public class TopologyUserLinkConfig implements Serializable { private String name; + @Override public String toString() { return name; } public static STATUS fromString(String str) { - if (str == null) + if (str == null) { return LINKDOWN; - if (str.equals(SUCCESS.toString())) + } + if (str.equals(SUCCESS.toString())) { return SUCCESS; - if (str.equals(LINKDOWN.toString())) + } + if (str.equals(LINKDOWN.toString())) { return LINKDOWN; - if (str.equals(INCORRECT.toString())) + } + if (str.equals(INCORRECT.toString())) { return INCORRECT; + } return LINKDOWN; } } @@ -111,19 +117,18 @@ public class TopologyUserLinkConfig implements Serializable { } public boolean isValidNodeConnector(String nodeConnectorStr) { - NodeConnector nc = NodeConnector.fromString(nodeConnectorStr); - if (nc == null) return false; - return true; + return (NodeConnector.fromString(nodeConnectorStr) != null); } public boolean isValid() { - if (name == null || srcNodeConnector == null || dstNodeConnector == null) { + if (!isValidResourceName(name)) { + logger.debug("Invalid name in user link: {}", name); return false; } if (!isValidNodeConnector(srcNodeConnector) || !isValidNodeConnector(dstNodeConnector)) { - logger.debug("Invalid NodeConnector in user link: {}", this); + logger.debug("Invalid NodeConnector in user link: {}", name); return false; } @@ -146,23 +151,30 @@ public class TopologyUserLinkConfig 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; + } TopologyUserLinkConfig other = (TopologyUserLinkConfig) obj; if (dstNodeConnector == null) { - if (other.dstNodeConnector != null) + if (other.dstNodeConnector != null) { return false; - } else if (!dstNodeConnector.equals(other.dstNodeConnector)) + } + } else if (!dstNodeConnector.equals(other.dstNodeConnector)) { return false; + } if (srcNodeConnector == null) { - if (other.srcNodeConnector != null) + if (other.srcNodeConnector != null) { return false; - } else if (!srcNodeConnector.equals(other.srcNodeConnector)) + } + } else if (!srcNodeConnector.equals(other.srcNodeConnector)) { return false; + } return true; }