Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.tetopology.management.api.link; |
| 17 | |
| 18 | import java.math.BigDecimal; |
| 19 | import java.math.BigInteger; |
| 20 | import java.util.List; |
| 21 | |
| 22 | import org.onosproject.tetopology.management.api.node.TeStatus; |
| 23 | |
| 24 | import com.google.common.base.MoreObjects; |
| 25 | import com.google.common.base.Objects; |
| 26 | |
| 27 | /** |
| 28 | * Link TE extension. |
| 29 | * <p> |
| 30 | * The Set/Get methods below are defined to accept and pass references because |
| 31 | * the object class is treated as a "composite" object class that holds |
| 32 | * references to various member objects and their relationships, forming a |
| 33 | * data tree. Internal routines of the TE topology manager may use the |
| 34 | * following example methods to construct and manipulate any piece of data in |
| 35 | * the data tree: |
| 36 | *<pre> |
| 37 | * newNode.getTe().setAdminStatus(), or |
| 38 | * newNode.getSupportingNodeIds().add(nodeId), etc. |
| 39 | *</pre> |
| 40 | * Same for constructors where, for example, a child list may be constructed |
| 41 | * first and passed in by reference to its parent object constructor. |
| 42 | */ |
| 43 | public class TeLink { |
| 44 | // See org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te. |
| 45 | // topology.rev20160708.ietftetopology |
| 46 | // .augmentedntlink.te.config.DefaultTeLinkAttributes for reference |
| 47 | private BigInteger linkIndex; |
| 48 | private String name; |
| 49 | private TeStatus adminStatus; |
| 50 | private TeStatus opStatus; |
| 51 | private TeLinkAccessType accessType; |
| 52 | //private administrativeGroup |
| 53 | private LinkProtectionType linkProtectionType; |
| 54 | private BigDecimal maxLinkBandwidth; |
| 55 | private BigDecimal maxResvLinkBandwidth; |
| 56 | private List<UnreservedBandwidth> unreservedBandwidths; |
| 57 | private long teDefaultMetric; |
| 58 | private ExternalDomain externalDomain; |
| 59 | private List<Long> teSrlgs; |
| 60 | private boolean isAbstract; |
| 61 | private UnderlayPath underlayPath; |
| 62 | |
| 63 | /** |
| 64 | * Creates an instance of TeLink. |
| 65 | * |
| 66 | * @param linkIndex TE link index |
| 67 | */ |
| 68 | public TeLink(BigInteger linkIndex) { |
| 69 | this.linkIndex = linkIndex; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Sets the name. |
| 74 | * |
| 75 | * @param name the name to set |
| 76 | */ |
| 77 | public void setName(String name) { |
| 78 | this.name = name; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Sets the administrative status. |
| 83 | * |
| 84 | * @param adminStatus the adminStatus to set |
| 85 | */ |
| 86 | public void setAdminStatus(TeStatus adminStatus) { |
| 87 | this.adminStatus = adminStatus; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Sets the operational status. |
| 92 | * |
| 93 | * @param opStatus the opStatus to set |
| 94 | */ |
| 95 | public void setOpStatus(TeStatus opStatus) { |
| 96 | this.opStatus = opStatus; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Sets the access type. |
| 101 | * |
| 102 | * @param accessType the accessType to set |
| 103 | */ |
| 104 | public void setAccessType(TeLinkAccessType accessType) { |
| 105 | this.accessType = accessType; |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Sets the protection type. |
| 110 | * |
| 111 | * @param type the linkProtectionType to set |
| 112 | */ |
| 113 | public void setLinkProtectionType(LinkProtectionType type) { |
| 114 | this.linkProtectionType = type; |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Sets the link maximum bandwidth. |
| 119 | * |
| 120 | * @param bw the maxLinkBandwidth to set |
| 121 | */ |
| 122 | public void setMaxLinkBandwidth(BigDecimal bw) { |
| 123 | this.maxLinkBandwidth = bw; |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * Sets the link maximum reservable bandwidth. |
| 128 | * |
| 129 | * @param bw the maxResvLinkBandwidth to set |
| 130 | */ |
| 131 | public void setMaxResvLinkBandwidth(BigDecimal bw) { |
| 132 | this.maxResvLinkBandwidth = bw; |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * Sets the list of link unreserved bandwidths. |
| 137 | * |
| 138 | * @param bwList the unreservedBandwidths to set |
| 139 | */ |
| 140 | public void setUnreservedBandwidths(List<UnreservedBandwidth> bwList) { |
| 141 | this.unreservedBandwidths = bwList; |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * Sets the default metric. |
| 146 | * |
| 147 | * @param metric the teDefaultMetric to set |
| 148 | */ |
| 149 | public void setTeDefaultMetric(long metric) { |
| 150 | this.teDefaultMetric = metric; |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * Sets the external domain link. |
| 155 | * |
| 156 | * @param extDomain the externalDomain to set |
| 157 | */ |
| 158 | public void setExternalDomain(ExternalDomain extDomain) { |
| 159 | this.externalDomain = extDomain; |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * Sets the list of SRLGs. |
| 164 | * |
| 165 | * @param teSrlgs the teSrlgs to set |
| 166 | */ |
| 167 | public void setTeSrlgs(List<Long> teSrlgs) { |
| 168 | this.teSrlgs = teSrlgs; |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * Sets the isAbstract flag. |
| 173 | * |
| 174 | * @param isAbstract the isAbstract to set |
| 175 | */ |
| 176 | public void setIsAbstract(boolean isAbstract) { |
| 177 | this.isAbstract = isAbstract; |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * Sets the link underlay path. |
| 182 | * |
| 183 | * @param underlayPath the underlay path to set |
| 184 | */ |
| 185 | public void setUnderlayPath(UnderlayPath underlayPath) { |
| 186 | this.underlayPath = underlayPath; |
| 187 | } |
| 188 | |
| 189 | /** |
| 190 | * Returns the link index. |
| 191 | * |
| 192 | * @return link index |
| 193 | */ |
| 194 | public BigInteger linkIndex() { |
| 195 | return linkIndex; |
| 196 | } |
| 197 | |
| 198 | /** |
| 199 | * Returns the name. |
| 200 | * |
| 201 | * @return name of the TE link |
| 202 | */ |
| 203 | public String name() { |
| 204 | return name; |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * Returns the administrative status. |
| 209 | * |
| 210 | * @return link admin status |
| 211 | */ |
| 212 | public TeStatus adminStatus() { |
| 213 | return adminStatus; |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * Returns the operational status. |
| 218 | * |
| 219 | * @return link operational status |
| 220 | */ |
| 221 | public TeStatus opStatus() { |
| 222 | return opStatus; |
| 223 | } |
| 224 | |
| 225 | /** |
| 226 | * Returns the access type. |
| 227 | * |
| 228 | * @return link access type |
| 229 | */ |
| 230 | public TeLinkAccessType accessType() { |
| 231 | return accessType; |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * Returns the link protection type. |
| 236 | * |
| 237 | * @return link protection type |
| 238 | */ |
| 239 | public LinkProtectionType linkProtectionType() { |
| 240 | return linkProtectionType; |
| 241 | } |
| 242 | |
| 243 | /** |
| 244 | * Returns the link maximum bandwidth. |
| 245 | * |
| 246 | * @return link maximum bandwidth |
| 247 | */ |
| 248 | public BigDecimal maxLinkBandwidth() { |
| 249 | return maxLinkBandwidth; |
| 250 | } |
| 251 | |
| 252 | /** |
| 253 | * Returns the maximum reservable bandwidth. |
| 254 | * |
| 255 | * @return link maximum reservable bandwidth |
| 256 | */ |
| 257 | public BigDecimal maxResvLinkBandwidth() { |
| 258 | return maxResvLinkBandwidth; |
| 259 | } |
| 260 | |
| 261 | /** |
| 262 | * Returns the list of link unreserved bandwidths. |
| 263 | * |
| 264 | * @return link unreserved bandwidth |
| 265 | */ |
| 266 | public List<UnreservedBandwidth> unreservedBandwidths() { |
| 267 | return unreservedBandwidths; |
| 268 | } |
| 269 | |
| 270 | /** |
| 271 | * Returns the te default metric. |
| 272 | * |
| 273 | * @return link TE metric |
| 274 | */ |
| 275 | public long teDefaultMetric() { |
| 276 | return teDefaultMetric; |
| 277 | } |
| 278 | |
| 279 | /** |
| 280 | * Returns the external domain link. |
| 281 | * |
| 282 | * @return external domain |
| 283 | */ |
| 284 | public ExternalDomain externalDomain() { |
| 285 | return externalDomain; |
| 286 | } |
| 287 | |
| 288 | /** |
| 289 | * Returns the list of SRLGs. |
| 290 | * |
| 291 | * @return link SRLG |
| 292 | */ |
| 293 | public List<Long> teSrlgs() { |
| 294 | return teSrlgs; |
| 295 | } |
| 296 | |
| 297 | /** |
| 298 | * Returns the flag isAbstract. |
| 299 | * |
| 300 | * @return true or false if link is abstract |
| 301 | */ |
| 302 | public boolean isAbstract() { |
| 303 | return isAbstract; |
| 304 | } |
| 305 | |
| 306 | /** |
| 307 | * Returns the underlay path data. |
| 308 | * |
| 309 | * @return link underlay TE path |
| 310 | */ |
| 311 | public UnderlayPath underlayPath() { |
| 312 | return underlayPath; |
| 313 | } |
| 314 | |
| 315 | @Override |
| 316 | public int hashCode() { |
| 317 | return Objects.hashCode(linkIndex, name, adminStatus, opStatus, accessType, |
| 318 | linkProtectionType, maxLinkBandwidth, maxResvLinkBandwidth, unreservedBandwidths, |
| 319 | teDefaultMetric, externalDomain, teSrlgs, isAbstract, underlayPath); |
| 320 | } |
| 321 | |
| 322 | @Override |
| 323 | public boolean equals(Object object) { |
| 324 | if (this == object) { |
| 325 | return true; |
| 326 | } |
| 327 | if (object instanceof TeLink) { |
| 328 | TeLink that = (TeLink) object; |
| 329 | return Objects.equal(this.linkIndex, that.linkIndex) && |
| 330 | Objects.equal(this.name, that.name) && |
| 331 | Objects.equal(this.adminStatus, that.adminStatus) && |
| 332 | Objects.equal(this.opStatus, that.opStatus) && |
| 333 | Objects.equal(this.accessType, that.accessType) && |
| 334 | Objects.equal(this.linkProtectionType, that.linkProtectionType) && |
| 335 | Objects.equal(this.maxLinkBandwidth, that.maxLinkBandwidth) && |
| 336 | Objects.equal(this.maxResvLinkBandwidth, that.maxResvLinkBandwidth) && |
| 337 | Objects.equal(this.unreservedBandwidths, that.unreservedBandwidths) && |
| 338 | Objects.equal(this.teDefaultMetric, that.teDefaultMetric) && |
| 339 | Objects.equal(this.externalDomain, that.externalDomain) && |
| 340 | Objects.equal(this.teSrlgs, that.teSrlgs) && |
| 341 | Objects.equal(this.isAbstract, that.isAbstract) && |
| 342 | Objects.equal(this.underlayPath, that.underlayPath); |
| 343 | } |
| 344 | return false; |
| 345 | } |
| 346 | |
| 347 | @Override |
| 348 | public String toString() { |
| 349 | return MoreObjects.toStringHelper(this) |
| 350 | .add("linkIndex", linkIndex) |
| 351 | .add("name", name) |
| 352 | .add("adminStatus", adminStatus) |
| 353 | .add("opStatus", opStatus) |
| 354 | .add("accessType", accessType) |
| 355 | .add("linkProtectionType", linkProtectionType) |
| 356 | .add("maxLinkBandwidth", maxLinkBandwidth) |
| 357 | .add("maxResvLinkBandwidth", maxResvLinkBandwidth) |
| 358 | .add("unreservedBandwidths", unreservedBandwidths) |
| 359 | .add("teDefaultMetric", teDefaultMetric) |
| 360 | .add("externalDomain", externalDomain) |
| 361 | .add("teSrlgs", teSrlgs) |
| 362 | .add("isAbstract", isAbstract) |
| 363 | .add("underlayPath", underlayPath) |
| 364 | .toString(); |
| 365 | } |
| 366 | |
| 367 | |
| 368 | } |