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.configuration.ConfigurationObject;
20 import org.opendaylight.controller.sal.core.NodeConnector;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
25 * The Interface provides methods to manipulate user configured link.
28 @XmlAccessorType(XmlAccessType.NONE)
29 public class TopologyUserLinkConfig extends ConfigurationObject implements Serializable {
30 private static final long serialVersionUID = 1L;
31 private static final Logger logger = LoggerFactory.getLogger(TopologyUserLinkConfig.class);
34 SUCCESS("Success"), LINKDOWN("Link Down"), INCORRECT(
35 "Incorrect Connection");
36 private STATUS(String name) {
43 public String toString() {
47 public static STATUS fromString(String str) {
51 if (str.equals(SUCCESS.toString())) {
54 if (str.equals(LINKDOWN.toString())) {
57 if (str.equals(INCORRECT.toString())) {
65 private String status;
69 private String srcNodeConnector;
71 private String dstNodeConnector;
73 public TopologyUserLinkConfig() {
75 status = STATUS.LINKDOWN.toString();
78 public TopologyUserLinkConfig(String name, String srcNodeConnector, String dstNodeConnector) {
81 this.srcNodeConnector = srcNodeConnector;
82 this.dstNodeConnector = dstNodeConnector;
86 public String getName() {
90 public void setName(String name) {
95 public STATUS getStatus() {
96 return STATUS.fromString(status);
99 public void setStatus(STATUS s) {
100 this.status = s.toString();
103 public String getSrcNodeConnector() {
104 return srcNodeConnector;
107 public void setSrcNodeConnector(String srcNodeConnector) {
108 this.srcNodeConnector = srcNodeConnector;
111 public String getDstNodeConnector() {
112 return dstNodeConnector;
115 public void setDstNodeConnector(String dstNodeConnector) {
116 this.dstNodeConnector = dstNodeConnector;
119 public boolean isValidNodeConnector(String nodeConnectorStr) {
120 return (NodeConnector.fromString(nodeConnectorStr) != null);
123 public boolean isValid() {
124 if (!isValidResourceName(name)) {
125 logger.debug("Invalid name in user link: {}", name);
129 if (!isValidNodeConnector(srcNodeConnector) ||
130 !isValidNodeConnector(dstNodeConnector)) {
131 logger.debug("Invalid NodeConnector in user link: {}", name);
139 public int hashCode() {
140 final int prime = 31;
144 + ((dstNodeConnector == null) ? 0 : dstNodeConnector.hashCode());
145 result = prime * result + ((name == null) ? 0 : name.hashCode());
148 + ((srcNodeConnector == null) ? 0 : srcNodeConnector.hashCode());
153 public boolean equals(Object obj) {
160 if (getClass() != obj.getClass()) {
163 TopologyUserLinkConfig other = (TopologyUserLinkConfig) obj;
164 if (dstNodeConnector == null) {
165 if (other.dstNodeConnector != null) {
168 } else if (!dstNodeConnector.equals(other.dstNodeConnector)) {
171 if (srcNodeConnector == null) {
172 if (other.srcNodeConnector != null) {
175 } else if (!srcNodeConnector.equals(other.srcNodeConnector)) {
182 public String toString() {
183 return "TopologyUserLinkConfig [status=" + status + ", name=" + name
184 + ", srcNodeConnector=" + srcNodeConnector
185 + ", dstNodeConnector=" + dstNodeConnector + "]";