blob: 963208463d942dd86a88593709e6f8826d3302a5 [file] [log] [blame]
Henry Yu4b4a7eb2016-11-09 20:07:53 -05001/*
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.BitSet;
19import java.util.Collections;
20import java.util.List;
21
22import com.google.common.collect.Lists;
23import org.onosproject.tetopology.management.api.link.ElementType;
24import org.onosproject.tetopology.management.api.link.TePathAttributes;
25import org.onosproject.tetopology.management.api.link.UnderlayAbstractPath;
26
27import com.google.common.base.MoreObjects;
28import com.google.common.base.Objects;
29
30/**
31 * The abstraction of a TE node internal connectivity to link
32 * termination points.
33 */
34public class AbstractConnectivity {
35 // list of elements that can be constrained/connected to
36 private final List<ElementType> constrainingElements;
37 private final BitSet flags;
38 private final TePathAttributes teAttributes;
39 private final UnderlayAbstractPath underlayPath;
40
41 /**
42 * Creates an abstract connectivity instance.
43 *
44 * @param constrainingElements list of elements that can be constrained
45 * or connected to
46 * @param flags indicate whether this connectivity is usable
47 * @param teAttributes the connectivity path TE attributes
48 * @param underlayPath the underlay path
49 */
50 public AbstractConnectivity(List<ElementType> constrainingElements,
51 BitSet flags,
52 TePathAttributes teAttributes,
53 UnderlayAbstractPath underlayPath) {
54 this.constrainingElements = Lists.newArrayList(constrainingElements);
55 this.flags = flags;
56 this.teAttributes = teAttributes;
57 this.underlayPath = underlayPath;
58 }
59
60 /**
61 * Returns the "constraining elements" that can be constrained
62 * or connected to "from" element.
63 *
64 * @return the "constraining elements" of the connectivity
65 */
66 public List<ElementType> constrainingElements() {
67 return Collections.unmodifiableList(constrainingElements);
68 }
69
70 /**
71 * Returns the flags indicating if the connectivity is usable.
72 *
73 * @return flags of the connectivity
74 */
75 public BitSet flags() {
76 return flags;
77 }
78
79 /**
80 * Returns the TE attributes of the connectivity.
81 *
82 * @return the TE attributes
83 */
84 public TePathAttributes teAttributes() {
85 return teAttributes;
86 }
87
88 /**
89 * Returns the underlay path.
90 *
91 * @return the underlay path
92 */
93 public UnderlayAbstractPath underlayPath() {
94 return underlayPath;
95 }
96
97 @Override
98 public int hashCode() {
99 return Objects.hashCode(constrainingElements, flags,
100 teAttributes, underlayPath);
101 }
102
103 @Override
104 public boolean equals(Object object) {
105 if (this == object) {
106 return true;
107 }
108 if (object instanceof AbstractConnectivity) {
109 AbstractConnectivity that = (AbstractConnectivity) object;
110 return Objects.equal(constrainingElements, that.constrainingElements) &&
111 Objects.equal(flags, that.flags) &&
112 Objects.equal(teAttributes, that.teAttributes) &&
113 Objects.equal(underlayPath, that.underlayPath);
114 }
115 return false;
116 }
117
118 @Override
119 public String toString() {
120 return MoreObjects.toStringHelper(this)
121 .add("constrainingElements", constrainingElements)
122 .add("flags", flags)
123 .add("teAttributes", teAttributes)
124 .add("underlayPath", underlayPath)
125 .toString();
126 }
127}