blob: f923b83f9584e0509f0f275091ec7cafcc835a7e [file] [log] [blame]
Andrea Campanella0c3309d2020-05-29 01:51:18 -07001/*
2 * Copyright 2020-present Open Networking Foundation
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.opencord.olt.impl;
17
18import org.onosproject.net.DeviceId;
19import org.onosproject.net.PortNumber;
20import org.onosproject.net.meter.MeterId;
21import org.opencord.sadis.UniTagInformation;
22
23import java.util.Objects;
24
25/**
26 * Contains the mapping of a given port to flow information, including bandwidth profile.
27 */
28class SubscriberFlowInfo {
29 private final DeviceId devId;
30 private final PortNumber nniPort;
31 private final PortNumber uniPort;
32 private final UniTagInformation tagInfo;
33 private MeterId downId;
34 private MeterId upId;
35 private final String downBpInfo;
36 private final String upBpInfo;
37
38 /**
39 * Builds the mapper of information.
40 * @param devId the device id
41 * @param nniPort the nni port
42 * @param uniPort the uni port
43 * @param tagInfo the tag info
44 * @param downId the downstream meter id
45 * @param upId the upstream meter id
46 * @param downBpInfo the downstream bandwidth profile
47 * @param upBpInfo the upstream bandwidth profile
48 */
49 SubscriberFlowInfo(DeviceId devId, PortNumber nniPort, PortNumber uniPort,
50 UniTagInformation tagInfo, MeterId downId, MeterId upId,
51 String downBpInfo, String upBpInfo) {
52 this.devId = devId;
53 this.nniPort = nniPort;
54 this.uniPort = uniPort;
55 this.tagInfo = tagInfo;
56 this.downId = downId;
57 this.upId = upId;
58 this.downBpInfo = downBpInfo;
59 this.upBpInfo = upBpInfo;
60 }
61
62 /**
63 * Gets the device id of this subscriber and flow information.
64 *
65 * @return device id
66 */
67 DeviceId getDevId() {
68 return devId;
69 }
70
71 /**
72 * Gets the nni of this subscriber and flow information.
73 *
74 * @return nni port
75 */
76 PortNumber getNniPort() {
77 return nniPort;
78 }
79
80 /**
81 * Gets the uni port of this subscriber and flow information.
82 *
83 * @return uni port
84 */
85 PortNumber getUniPort() {
86 return uniPort;
87 }
88
89 /**
90 * Gets the tag of this subscriber and flow information.
91 *
92 * @return tag of the subscriber
93 */
94 UniTagInformation getTagInfo() {
95 return tagInfo;
96 }
97
98 /**
99 * Gets the downstream meter id of this subscriber and flow information.
100 *
101 * @return downstream meter id
102 */
103 MeterId getDownId() {
104 return downId;
105 }
106
107 /**
108 * Gets the upstream meter id of this subscriber and flow information.
109 *
110 * @return upstream meter id
111 */
112 MeterId getUpId() {
113 return upId;
114 }
115
116 /**
117 * Gets the downstream bandwidth profile of this subscriber and flow information.
118 *
119 * @return downstream bandwidth profile
120 */
121 String getDownBpInfo() {
122 return downBpInfo;
123 }
124
125 /**
126 * Gets the upstream bandwidth profile of this subscriber and flow information.
127 *
128 * @return upstream bandwidth profile.
129 */
130 String getUpBpInfo() {
131 return upBpInfo;
132 }
133
134 /**
135 * Sets the upstream meter id.
136 * @param upMeterId the upstream meter id
137 */
138 void setUpMeterId(MeterId upMeterId) {
139 this.upId = upMeterId;
140 }
141
142 /**
143 * Sets the downstream meter id.
144 * @param downMeterId the downstream meter id
145 */
146 void setDownMeterId(MeterId downMeterId) {
147 this.downId = downMeterId;
148 }
149
150 @Override
151 public boolean equals(Object o) {
152 if (this == o) {
153 return true;
154 }
155 if (o == null || getClass() != o.getClass()) {
156 return false;
157 }
158 SubscriberFlowInfo flowInfo = (SubscriberFlowInfo) o;
159 return devId.equals(flowInfo.devId) &&
160 nniPort.equals(flowInfo.nniPort) &&
161 uniPort.equals(flowInfo.uniPort) &&
162 tagInfo.equals(flowInfo.tagInfo) &&
163 downId.equals(flowInfo.downId) &&
164 upId.equals(flowInfo.upId) &&
165 downBpInfo.equals(flowInfo.downBpInfo) &&
166 upBpInfo.equals(flowInfo.upBpInfo);
167 }
168
169 @Override
170 public int hashCode() {
171 return Objects.hash(devId, nniPort, uniPort, tagInfo, downId, upId, downBpInfo, upBpInfo);
172 }
173
174 @Override
175 public String toString() {
176 return com.google.common.base.MoreObjects.toStringHelper(this)
177 .add("devId", devId)
178 .add("nniPort", nniPort)
179 .add("uniPort", uniPort)
180 .add("tagInfo", tagInfo)
181 .add("downId", downId)
182 .add("upId", upId)
183 .add("downBpInfo", downBpInfo)
184 .add("upBpInfo", upBpInfo)
185 .toString();
186 }
187}