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
13 * @brief Describe an edge in network made of multiple SDN technologies
15 * Class that describe an Edge connecting two NodeConnector, the edge
16 * is directed because there is the head and the tail concept which
17 * implies a direction.
19 package org.opendaylight.controller.sal.core;
21 import java.io.Serializable;
23 import javax.xml.bind.annotation.XmlAccessType;
24 import javax.xml.bind.annotation.XmlAccessorType;
25 import javax.xml.bind.annotation.XmlElement;
26 import javax.xml.bind.annotation.XmlRootElement;
30 * Class that describe an Edge connecting two NodeConnector, the edge
31 * is directed because there is the tail and the head concept which
32 * implies a direction.
36 @XmlAccessorType(XmlAccessType.NONE)
37 public class Edge implements Serializable {
38 private static final long serialVersionUID = 1L;
40 private NodeConnector tailNodeConnector;
42 private NodeConnector headNodeConnector;
45 * Private constructor used for JAXB mapping
47 @SuppressWarnings("unused")
49 this.tailNodeConnector = null;
50 this.headNodeConnector = null;
56 * @param tailNodeConnector Tail Node output connector
57 * @param headNodeConnector Head Node input connector
60 public Edge(NodeConnector tailNodeConnector, NodeConnector headNodeConnector)
61 throws ConstructionException {
62 if (tailNodeConnector == null || headNodeConnector == null) {
63 throw new ConstructionException(
64 "Null tail or head NodeConnector supplied");
66 this.tailNodeConnector = tailNodeConnector;
67 this.headNodeConnector = headNodeConnector;
72 * Copy Construct the Edge
74 * @param src Edge to copy from
77 public Edge(Edge src) throws ConstructionException {
79 this.tailNodeConnector = new NodeConnector(src
80 .getTailNodeConnector());
81 this.headNodeConnector = new NodeConnector(src
82 .getHeadNodeConnector());
84 throw new ConstructionException("src supplied was null");
92 * @return tail NodeConnector of the edge
94 public NodeConnector getTailNodeConnector() {
95 return tailNodeConnector;
101 * @param tailNodeConnector NodeConnector to set the tail
103 public void setTailNodeConnector(NodeConnector tailNodeConnector) {
104 this.tailNodeConnector = tailNodeConnector;
111 * @return head NodeConnector of the edge
113 public NodeConnector getHeadNodeConnector() {
114 return headNodeConnector;
120 * @param headNodeConnector NodeConnector to set the head
122 public void setHeadNodeConnector(NodeConnector headNodeConnector) {
123 this.headNodeConnector = headNodeConnector;
127 public int hashCode() {
128 final int prime = 31;
132 + ((headNodeConnector == null) ? 0 : headNodeConnector
136 + ((tailNodeConnector == null) ? 0 : tailNodeConnector
142 public boolean equals(Object obj) {
147 if (getClass() != obj.getClass())
149 Edge other = (Edge) obj;
150 if (headNodeConnector == null) {
151 if (other.headNodeConnector != null)
153 } else if (!headNodeConnector.equals(other.headNodeConnector))
155 if (tailNodeConnector == null) {
156 if (other.tailNodeConnector != null)
158 } else if (!tailNodeConnector.equals(other.tailNodeConnector))
164 public String toString() {
165 return "(" + this.tailNodeConnector + "->" + this.headNodeConnector