Make sure invokeOperation is set once
[controller.git] / opendaylight / adsal / sal / api / src / main / java / org / opendaylight / controller / sal / core / Edge.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
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
8  */
9
10 /**
11  * @file   Edge.java
12  *
13  * @brief  Describe an edge in network made of multiple SDN technologies
14  *
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.
18  */
19 package org.opendaylight.controller.sal.core;
20
21 import java.io.Serializable;
22
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;
27
28 /**
29  *
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.
33  *
34  */
35 @XmlRootElement
36 @XmlAccessorType(XmlAccessType.NONE)
37 @Deprecated
38 public class Edge implements Serializable {
39     private static final long serialVersionUID = 1L;
40     @XmlElement
41     private NodeConnector tailNodeConnector;
42     @XmlElement
43     private NodeConnector headNodeConnector;
44
45     /**
46      * Private constructor used for JAXB mapping
47      */
48     @SuppressWarnings("unused")
49     private Edge() {
50         this.tailNodeConnector = null;
51         this.headNodeConnector = null;
52     }
53
54     /**
55      * Construct the Edge
56      *
57      * @param tailNodeConnector Tail Node output connector
58      * @param headNodeConnector Head Node input connector
59      *
60      */
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");
66         } else {
67             this.tailNodeConnector = tailNodeConnector;
68             this.headNodeConnector = headNodeConnector;
69         }
70     }
71
72     /**
73      * Copy Construct the Edge
74      *
75      * @param src Edge to copy from
76      *
77      */
78     public Edge(Edge src) throws ConstructionException {
79         if (src != null) {
80             this.tailNodeConnector = new NodeConnector(src
81                     .getTailNodeConnector());
82             this.headNodeConnector = new NodeConnector(src
83                     .getHeadNodeConnector());
84         } else {
85             throw new ConstructionException("src supplied was null");
86         }
87     }
88
89     /**
90      * Create the reversed edge
91      * @return The reversed edge.
92      */
93     public Edge reverse() {
94         Edge re;
95         try {
96             re = new Edge(this.headNodeConnector, this.tailNodeConnector);
97         } catch (ConstructionException e) {
98             re = null;
99         }
100         return re;
101     }
102     /**
103      * getter of edge
104      *
105      *
106      * @return tail NodeConnector of the edge
107      */
108     public NodeConnector getTailNodeConnector() {
109         return tailNodeConnector;
110     }
111
112     /**
113      * setter for edge
114      *
115      * @param tailNodeConnector NodeConnector to set the tail
116      */
117     public void setTailNodeConnector(NodeConnector tailNodeConnector) {
118         this.tailNodeConnector = tailNodeConnector;
119     }
120
121     /**
122      * getter of edge
123      *
124      *
125      * @return head NodeConnector of the edge
126      */
127     public NodeConnector getHeadNodeConnector() {
128         return headNodeConnector;
129     }
130
131     /**
132      * setter for edge
133      *
134      * @param headNodeConnector NodeConnector to set the head
135      */
136     public void setHeadNodeConnector(NodeConnector headNodeConnector) {
137         this.headNodeConnector = headNodeConnector;
138     }
139
140     @Override
141     public int hashCode() {
142         final int prime = 31;
143         int result = 1;
144         result = prime
145                 * result
146                 + ((headNodeConnector == null) ? 0 : headNodeConnector
147                         .hashCode());
148         result = prime
149                 * result
150                 + ((tailNodeConnector == null) ? 0 : tailNodeConnector
151                         .hashCode());
152         return result;
153     }
154
155     @Override
156     public boolean equals(Object obj) {
157         if (this == obj)
158             return true;
159         if (obj == null)
160             return false;
161         if (getClass() != obj.getClass())
162             return false;
163         Edge other = (Edge) obj;
164         if (headNodeConnector == null) {
165             if (other.headNodeConnector != null)
166                 return false;
167         } else if (!headNodeConnector.equals(other.headNodeConnector))
168             return false;
169         if (tailNodeConnector == null) {
170             if (other.tailNodeConnector != null)
171                 return false;
172         } else if (!tailNodeConnector.equals(other.tailNodeConnector))
173             return false;
174         return true;
175     }
176
177     @Override
178     public String toString() {
179         return "(" + this.tailNodeConnector + "->" + this.headNodeConnector
180                 + ")";
181     }
182 }