3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.controller.topologymanager;
12 import java.io.Serializable;
14 import javax.xml.bind.annotation.XmlAccessType;
15 import javax.xml.bind.annotation.XmlAccessorType;
16 import javax.xml.bind.annotation.XmlElement;
17 import javax.xml.bind.annotation.XmlRootElement;
19 import org.opendaylight.controller.sal.core.NodeConnector;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
24 * The Interface provides methods to manipulate user configured link.
27 @XmlAccessorType(XmlAccessType.NONE)
28 public class TopologyUserLinkConfig implements Serializable {
29 private static final long serialVersionUID = 1L;
30 private static final Logger logger = LoggerFactory.getLogger(TopologyUserLinkConfig.class);
33 SUCCESS("Success"), LINKDOWN("Link Down"), INCORRECT(
34 "Incorrect Connection");
35 private STATUS(String name) {
41 public String toString() {
45 public static STATUS fromString(String str) {
48 if (str.equals(SUCCESS.toString()))
50 if (str.equals(LINKDOWN.toString()))
52 if (str.equals(INCORRECT.toString()))
59 private String status;
63 private String srcNodeConnector;
65 private String dstNodeConnector;
67 public TopologyUserLinkConfig() {
69 status = STATUS.LINKDOWN.toString();
72 public TopologyUserLinkConfig(String name, String srcNodeConnector, String dstNodeConnector) {
75 this.srcNodeConnector = srcNodeConnector;
76 this.dstNodeConnector = dstNodeConnector;
80 public String getName() {
84 public void setName(String name) {
89 public STATUS getStatus() {
90 return STATUS.fromString(status);
93 public void setStatus(STATUS s) {
94 this.status = s.toString();
97 public String getSrcNodeConnector() {
98 return srcNodeConnector;
101 public void setSrcNodeConnector(String srcNodeConnector) {
102 this.srcNodeConnector = srcNodeConnector;
105 public String getDstNodeConnector() {
106 return dstNodeConnector;
109 public void setDstNodeConnector(String dstNodeConnector) {
110 this.dstNodeConnector = dstNodeConnector;
113 public boolean isValidNodeConnector(String nodeConnectorStr) {
114 NodeConnector nc = NodeConnector.fromString(nodeConnectorStr);
115 if (nc == null) return false;
119 public boolean isValid() {
120 if (name == null || srcNodeConnector == null || dstNodeConnector == null) {
124 if (!isValidNodeConnector(srcNodeConnector) ||
125 !isValidNodeConnector(dstNodeConnector)) {
126 logger.debug("Invalid NodeConnector in user link: {}", this);
134 public int hashCode() {
135 final int prime = 31;
139 + ((dstNodeConnector == null) ? 0 : dstNodeConnector.hashCode());
140 result = prime * result + ((name == null) ? 0 : name.hashCode());
143 + ((srcNodeConnector == null) ? 0 : srcNodeConnector.hashCode());
148 public boolean equals(Object obj) {
153 if (getClass() != obj.getClass())
155 TopologyUserLinkConfig other = (TopologyUserLinkConfig) obj;
156 if (dstNodeConnector == null) {
157 if (other.dstNodeConnector != null)
159 } else if (!dstNodeConnector.equals(other.dstNodeConnector))
161 if (srcNodeConnector == null) {
162 if (other.srcNodeConnector != null)
164 } else if (!srcNodeConnector.equals(other.srcNodeConnector))
170 public String toString() {
171 return "TopologyUserLinkConfig [status=" + status + ", name=" + name
172 + ", srcNodeConnector=" + srcNodeConnector
173 + ", dstNodeConnector=" + dstNodeConnector + "]";