Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 1 | /* |
Joey Armstrong | 7f6d6d2 | 2023-01-09 17:09:50 -0500 | [diff] [blame] | 2 | * Copyright 2021-2023 Open Networking Foundation (ONF) and the ONF Contributors |
Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 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 | |
Gustavo Silva | 29fb20e | 2022-05-26 09:59:54 -0300 | [diff] [blame] | 17 | package org.opencord.olt; |
Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 18 | |
| 19 | import org.onosproject.net.meter.MeterCellId; |
| 20 | import org.onosproject.net.meter.MeterId; |
| 21 | import org.onosproject.net.meter.MeterState; |
| 22 | |
| 23 | import java.util.Objects; |
| 24 | |
| 25 | /** |
| 26 | * Class containing Meter Data. |
| 27 | */ |
| 28 | public class MeterData { |
| 29 | private MeterCellId meterCellId; |
| 30 | private MeterState meterStatus; |
| 31 | private String bandwidthProfileName; |
| 32 | |
Gustavo Silva | 29fb20e | 2022-05-26 09:59:54 -0300 | [diff] [blame] | 33 | /** |
| 34 | * Creates a MeterData for a given cellid, status and bandwidth profile. |
| 35 | * |
| 36 | * @param meterCellId the cell id |
| 37 | * @param meterStatus the status |
| 38 | * @param bandwidthProfile the bandwidth profile |
| 39 | */ |
Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 40 | public MeterData(MeterCellId meterCellId, MeterState meterStatus, String bandwidthProfile) { |
| 41 | this.meterCellId = meterCellId; |
| 42 | this.meterStatus = meterStatus; |
| 43 | this.bandwidthProfileName = bandwidthProfile; |
| 44 | } |
| 45 | |
Gustavo Silva | 29fb20e | 2022-05-26 09:59:54 -0300 | [diff] [blame] | 46 | /** |
| 47 | * Sets the meter cell id. |
| 48 | * |
| 49 | * @param meterCellId the meter cell id. |
| 50 | */ |
Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 51 | public void setMeterCellId(MeterCellId meterCellId) { |
| 52 | this.meterCellId = meterCellId; |
| 53 | } |
| 54 | |
Gustavo Silva | 29fb20e | 2022-05-26 09:59:54 -0300 | [diff] [blame] | 55 | /** |
| 56 | * Sets the meter status. |
| 57 | * |
| 58 | * @param meterStatus the meter status. |
| 59 | */ |
Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 60 | public void setMeterStatus(MeterState meterStatus) { |
| 61 | this.meterStatus = meterStatus; |
| 62 | } |
| 63 | |
Gustavo Silva | 29fb20e | 2022-05-26 09:59:54 -0300 | [diff] [blame] | 64 | /** |
| 65 | * Gets the meter id. |
| 66 | * |
| 67 | * @return Meter id. |
| 68 | */ |
Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 69 | public MeterId getMeterId() { |
| 70 | return (MeterId) meterCellId; |
| 71 | } |
| 72 | |
Gustavo Silva | 29fb20e | 2022-05-26 09:59:54 -0300 | [diff] [blame] | 73 | /** |
| 74 | * Gets the meter cell id. |
| 75 | * |
| 76 | * @return Meter cell id. |
| 77 | */ |
Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 78 | public MeterCellId getMeterCellId() { |
| 79 | return meterCellId; |
| 80 | } |
| 81 | |
Gustavo Silva | 29fb20e | 2022-05-26 09:59:54 -0300 | [diff] [blame] | 82 | /** |
| 83 | * Gets the meter status. |
| 84 | * |
| 85 | * @return Meter status. |
| 86 | */ |
Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 87 | public MeterState getMeterStatus() { |
| 88 | return meterStatus; |
| 89 | } |
| 90 | |
Gustavo Silva | 29fb20e | 2022-05-26 09:59:54 -0300 | [diff] [blame] | 91 | /** |
| 92 | * Gets the bandwidth profile name. |
| 93 | * |
| 94 | * @return Bandwidth profile name. |
| 95 | */ |
Matteo Scandolo | aa2adde | 2021-09-13 12:45:32 -0700 | [diff] [blame] | 96 | public String getBandwidthProfileName() { |
| 97 | return bandwidthProfileName; |
| 98 | } |
| 99 | |
| 100 | @Override |
| 101 | public boolean equals(Object o) { |
| 102 | if (this == o) { |
| 103 | return true; |
| 104 | } |
| 105 | if (o == null || getClass() != o.getClass()) { |
| 106 | return false; |
| 107 | } |
| 108 | MeterData meterData = (MeterData) o; |
| 109 | return Objects.equals(meterCellId, meterData.meterCellId) && |
| 110 | meterStatus == meterData.meterStatus && |
| 111 | Objects.equals(bandwidthProfileName, meterData.bandwidthProfileName); |
| 112 | } |
| 113 | |
| 114 | @Override |
| 115 | public int hashCode() { |
| 116 | return Objects.hash(meterCellId, meterStatus, bandwidthProfileName); |
| 117 | } |
| 118 | |
| 119 | @Override |
| 120 | public String toString() { |
| 121 | return "MeterData{" + |
| 122 | "meterCellId=" + meterCellId + |
| 123 | ", meterStatus=" + meterStatus + |
| 124 | ", bandwidthProfile='" + bandwidthProfileName + '\'' + |
| 125 | '}'; |
| 126 | } |
| 127 | } |