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;
*/
@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);
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;
}
}
}
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;
}
@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;
}