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
48 this.tailNodeConnector = null;
49 this.headNodeConnector = null;
55 * @param tailNodeConnector Tail Node output connector
56 * @param headNodeConnector Head Node input connector
59 public Edge(NodeConnector tailNodeConnector, NodeConnector headNodeConnector)
60 throws ConstructionException {
61 if (tailNodeConnector == null || headNodeConnector == null) {
62 throw new ConstructionException(
63 "Null tail or head NodeConnector supplied");
65 this.tailNodeConnector = tailNodeConnector;
66 this.headNodeConnector = headNodeConnector;
71 * Copy Construct the Edge
73 * @param src Edge to copy from
76 public Edge(Edge src) throws ConstructionException {
78 this.tailNodeConnector = new NodeConnector(src
79 .getTailNodeConnector());
80 this.headNodeConnector = new NodeConnector(src
81 .getHeadNodeConnector());
83 throw new ConstructionException("src supplied was null");
91 * @return tail NodeConnector of the edge
93 public NodeConnector getTailNodeConnector() {
94 return tailNodeConnector;
100 * @param tailNodeConnector NodeConnector to set the tail
102 public void setTailNodeConnector(NodeConnector tailNodeConnector) {
103 this.tailNodeConnector = tailNodeConnector;
110 * @return head NodeConnector of the edge
112 public NodeConnector getHeadNodeConnector() {
113 return headNodeConnector;
119 * @param headNodeConnector NodeConnector to set the head
121 public void setHeadNodeConnector(NodeConnector headNodeConnector) {
122 this.headNodeConnector = headNodeConnector;
126 public int hashCode() {
127 final int prime = 31;
131 + ((headNodeConnector == null) ? 0 : headNodeConnector
135 + ((tailNodeConnector == null) ? 0 : tailNodeConnector
141 public boolean equals(Object obj) {
146 if (getClass() != obj.getClass())
148 Edge other = (Edge) obj;
149 if (headNodeConnector == null) {
150 if (other.headNodeConnector != null)
152 } else if (!headNodeConnector.equals(other.headNodeConnector))
154 if (tailNodeConnector == null) {
155 if (other.tailNodeConnector != null)
157 } else if (!tailNodeConnector.equals(other.tailNodeConnector))
163 public String toString() {
164 return "(" + this.tailNodeConnector + "->" + this.headNodeConnector