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)
38 public class Edge implements Serializable {
39 private static final long serialVersionUID = 1L;
41 private NodeConnector tailNodeConnector;
43 private NodeConnector headNodeConnector;
46 * Private constructor used for JAXB mapping
48 @SuppressWarnings("unused")
50 this.tailNodeConnector = null;
51 this.headNodeConnector = null;
57 * @param tailNodeConnector Tail Node output connector
58 * @param headNodeConnector Head Node input connector
61 public Edge(NodeConnector tailNodeConnector, NodeConnector headNodeConnector)
62 throws ConstructionException {
63 if (tailNodeConnector == null || headNodeConnector == null) {
64 throw new ConstructionException(
65 "Null tail or head NodeConnector supplied");
67 this.tailNodeConnector = tailNodeConnector;
68 this.headNodeConnector = headNodeConnector;
73 * Copy Construct the Edge
75 * @param src Edge to copy from
78 public Edge(Edge src) throws ConstructionException {
80 this.tailNodeConnector = new NodeConnector(src
81 .getTailNodeConnector());
82 this.headNodeConnector = new NodeConnector(src
83 .getHeadNodeConnector());
85 throw new ConstructionException("src supplied was null");
90 * Create the reversed edge
91 * @return The reversed edge.
93 public Edge reverse() {
96 re = new Edge(this.headNodeConnector, this.tailNodeConnector);
97 } catch (ConstructionException e) {
106 * @return tail NodeConnector of the edge
108 public NodeConnector getTailNodeConnector() {
109 return tailNodeConnector;
115 * @param tailNodeConnector NodeConnector to set the tail
117 public void setTailNodeConnector(NodeConnector tailNodeConnector) {
118 this.tailNodeConnector = tailNodeConnector;
125 * @return head NodeConnector of the edge
127 public NodeConnector getHeadNodeConnector() {
128 return headNodeConnector;
134 * @param headNodeConnector NodeConnector to set the head
136 public void setHeadNodeConnector(NodeConnector headNodeConnector) {
137 this.headNodeConnector = headNodeConnector;
141 public int hashCode() {
142 final int prime = 31;
146 + ((headNodeConnector == null) ? 0 : headNodeConnector
150 + ((tailNodeConnector == null) ? 0 : tailNodeConnector
156 public boolean equals(Object obj) {
161 if (getClass() != obj.getClass())
163 Edge other = (Edge) obj;
164 if (headNodeConnector == null) {
165 if (other.headNodeConnector != null)
167 } else if (!headNodeConnector.equals(other.headNodeConnector))
169 if (tailNodeConnector == null) {
170 if (other.tailNodeConnector != null)
172 } else if (!tailNodeConnector.equals(other.tailNodeConnector))
178 public String toString() {
179 return "(" + this.tailNodeConnector + "->" + this.headNodeConnector