blob: 0eef01c95390dc84c18a0f9557ab9814cedb0758 [file] [log] [blame]
Aihua Guo1ce2dd12016-08-12 23:37:44 -04001/*
2 * Copyright 2016 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.tetopology.management.api.node;
17
18import java.util.List;
19
20import com.google.common.base.MoreObjects;
21import com.google.common.base.Objects;
22
23/**
24 * TE Node representation.
25 * <p>
26 * The Set/Get methods below are defined to accept and pass references because
27 * the object class is treated as a "composite" object class that holds
28 * references to various member objects and their relationships, forming a
29 * data tree. Internal routines of the TE topology manager may use the
30 * following example methods to construct and manipulate any piece of data in
31 * the data tree:
32 * <pre>
33 * newNode.getTe().setAdminStatus(), or
34 * newNode.getSupportingNodeIds().add(nodeId), etc.
35 * </pre>
36 * Same for constructors where, for example, a child list may be constructed
37 * first and passed in by reference to its parent object constructor.
38 */
39public class TeNode {
40 // See org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.
41 // topology.rev20160708.ietftetopology
42 // .augmentednwnode.te.config.DefaultTeNodeAttributes for reference
43 private String teNodeId;
44 private String name;
45 private TeStatus adminStatus;
46 private TeStatus opStatus;
47 private boolean isAbstract;
48 private List<ConnectivityMatrix> connMatrices;
49 private TeNetworkTopologyId underlayTopology;
50 private List<TunnelTerminationPoint> tunnelTerminationPoints;
51
52 /**
53 * Creates an instance of TeNode.
54 *
55 * @param teNodeId TE node identifier
56 */
57 public TeNode(String teNodeId) {
58 this.teNodeId = teNodeId;
59 }
60
61 /**
62 * Sets the node name.
63 *
64 * @param name the name to set
65 */
66 public void setName(String name) {
67 this.name = name;
68 }
69
70 /**
71 * Sets the node administrative status.
72 *
73 * @param adminStatus the adminStatus to set
74 */
75 public void setAdminStatus(TeStatus adminStatus) {
76 this.adminStatus = adminStatus;
77 }
78
79 /**
80 * Sets the node operational status.
81 *
82 * @param opStatus the opStatus to set
83 */
84 public void setOpStatus(TeStatus opStatus) {
85 this.opStatus = opStatus;
86 }
87
88 /**
89 * Sets the node is an abstract node or not.
90 *
91 * @param isAbstract the isAbstract to set
92 */
93 public void setAbstract(boolean isAbstract) {
94 this.isAbstract = isAbstract;
95 }
96
97 /**
98 * Set connectivity matrix table.
99 *
100 * @param connMatrices connectivity matrix table
101 */
102 public void setConnectivityMatrices(List<ConnectivityMatrix> connMatrices) {
103 this.connMatrices = connMatrices;
104 }
105
106 /**
107 * Sets the node underlay TE topology.
108 *
109 * @param topo the underlayTopology to set
110 */
111 public void setUnderlayTopology(TeNetworkTopologyId topo) {
112 this.underlayTopology = topo;
113 }
114
115 /**
116 * Sets the list of tunnel termination points.
117 *
118 * @param ttps the tunnelTerminationPoints to set
119 */
120 public void setTunnelTerminationPoints(List<TunnelTerminationPoint> ttps) {
121 this.tunnelTerminationPoints = ttps;
122 }
123
124 /**
125 * Returns the teNodeId.
126 *
127 * @return TE node id
128 */
129 public String teNodeId() {
130 return teNodeId;
131 }
132
133 /**
134 * Returns the name.
135 *
136 * @return TE node name
137 */
138 public String name() {
139 return name;
140 }
141
142 /**
143 * Returns the adminStatus.
144 *
145 * @return TE node admin status
146 */
147 public TeStatus adminStatus() {
148 return adminStatus;
149 }
150
151 /**
152 * Returns the opStatus.
153 *
154 * @return TE node operational status
155 */
156 public TeStatus opStatus() {
157 return opStatus;
158 }
159
160 /**
161 * Returns the isAbstract.
162 *
163 * @return true or false if the TE node is abstract
164 */
165 public boolean isAbstract() {
166 return isAbstract;
167 }
168
169 /**
170 * Returns the connectivity matrix table.
171 *
172 * @return node connectivity matrix table
173 */
174 public List<ConnectivityMatrix> connectivityMatrices() {
175 return connMatrices;
176 }
177
178 /**
179 * Returns the underlay topology.
180 *
181 * @return node underlay topology
182 */
183 public TeNetworkTopologyId underlayTopology() {
184 return underlayTopology;
185 }
186
187 /**
188 * Returns the tunnelTerminationPoints.
189 *
190 * @return list of tunnel terminational points
191 */
192 public List<TunnelTerminationPoint> tunnelTerminationPoints() {
193 return tunnelTerminationPoints;
194 }
195
196 @Override
197 public int hashCode() {
198 return Objects.hashCode(teNodeId, name, adminStatus, opStatus, isAbstract,
199 connMatrices, underlayTopology, tunnelTerminationPoints);
200 }
201
202 @Override
203 public boolean equals(Object object) {
204 if (this == object) {
205 return true;
206 }
207 if (object instanceof TeNode) {
208 TeNode that = (TeNode) object;
209 return Objects.equal(this.teNodeId, that.teNodeId) &&
210 Objects.equal(this.name, that.name) &&
211 Objects.equal(this.adminStatus, that.adminStatus) &&
212 Objects.equal(this.opStatus, that.opStatus) &&
213 Objects.equal(this.isAbstract, that.isAbstract) &&
214 Objects.equal(this.connMatrices, that.connMatrices) &&
215 Objects.equal(this.underlayTopology, that.underlayTopology) &&
216 Objects.equal(this.tunnelTerminationPoints, that.tunnelTerminationPoints);
217 }
218 return false;
219 }
220
221 @Override
222 public String toString() {
223 return MoreObjects.toStringHelper(this)
224 .add("teNodeId", teNodeId)
225 .add("name", name)
226 .add("adminStatus", adminStatus)
227 .add("opStatus", opStatus)
228 .add("isAbstract", isAbstract)
229 .add("connMatrices", connMatrices)
230 .add("underlayTopology", underlayTopology)
231 .add("tunnelTerminationPoints", tunnelTerminationPoints)
232 .toString();
233 }
234
235}