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");
89 * Create the reversed edge
90 * @return The reversed edge.
92 public Edge reverse() {
95 re = new Edge(this.headNodeConnector, this.tailNodeConnector);
96 } catch (ConstructionException e) {
105 * @return tail NodeConnector of the edge
107 public NodeConnector getTailNodeConnector() {
108 return tailNodeConnector;
114 * @param tailNodeConnector NodeConnector to set the tail
116 public void setTailNodeConnector(NodeConnector tailNodeConnector) {
117 this.tailNodeConnector = tailNodeConnector;
124 * @return head NodeConnector of the edge
126 public NodeConnector getHeadNodeConnector() {
127 return headNodeConnector;
133 * @param headNodeConnector NodeConnector to set the head
135 public void setHeadNodeConnector(NodeConnector headNodeConnector) {
136 this.headNodeConnector = headNodeConnector;
140 public int hashCode() {
141 final int prime = 31;
145 + ((headNodeConnector == null) ? 0 : headNodeConnector
149 + ((tailNodeConnector == null) ? 0 : tailNodeConnector
155 public boolean equals(Object obj) {
160 if (getClass() != obj.getClass())
162 Edge other = (Edge) obj;
163 if (headNodeConnector == null) {
164 if (other.headNodeConnector != null)
166 } else if (!headNodeConnector.equals(other.headNodeConnector))
168 if (tailNodeConnector == null) {
169 if (other.tailNodeConnector != null)
171 } else if (!tailNodeConnector.equals(other.tailNodeConnector))
177 public String toString() {
178 return "(" + this.tailNodeConnector + "->" + this.headNodeConnector