Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
Andrea Campanella | 3ce4d28 | 2020-06-09 13:46:58 +0200 | [diff] [blame] | 16 | package org.opencord.olt.internalapi; |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 17 | |
| 18 | import org.onosproject.net.DeviceId; |
| 19 | import org.opencord.sadis.BandwidthProfileInformation; |
| 20 | |
| 21 | import java.util.Objects; |
| 22 | |
| 23 | /** |
| 24 | * Class containing a mapping of DeviceId to BandwidthProfileInformation. |
| 25 | */ |
Andrea Campanella | 3ce4d28 | 2020-06-09 13:46:58 +0200 | [diff] [blame] | 26 | public class DeviceBandwidthProfile { |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 27 | private final DeviceId devId; |
| 28 | private BandwidthProfileInformation bwInfo; |
| 29 | |
| 30 | /** |
| 31 | * Creates the Mapping. |
| 32 | * |
| 33 | * @param devId the device id |
| 34 | * @param bwInfo the bandwidth profile information |
| 35 | */ |
Andrea Campanella | 3ce4d28 | 2020-06-09 13:46:58 +0200 | [diff] [blame] | 36 | public DeviceBandwidthProfile(DeviceId devId, BandwidthProfileInformation bwInfo) { |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 37 | this.devId = devId; |
| 38 | this.bwInfo = bwInfo; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Returns the device id. |
| 43 | * |
| 44 | * @return device id. |
| 45 | */ |
Andrea Campanella | 3ce4d28 | 2020-06-09 13:46:58 +0200 | [diff] [blame] | 46 | public DeviceId getDevId() { |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 47 | return devId; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Returns the Bandwidth profile for this device. |
| 52 | * |
| 53 | * @return bandwidth profile information |
| 54 | */ |
Andrea Campanella | 3ce4d28 | 2020-06-09 13:46:58 +0200 | [diff] [blame] | 55 | public BandwidthProfileInformation getBwInfo() { |
Andrea Campanella | 0c3309d | 2020-05-29 01:51:18 -0700 | [diff] [blame] | 56 | return bwInfo; |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public boolean equals(Object o) { |
| 61 | if (this == o) { |
| 62 | return true; |
| 63 | } |
| 64 | if (o == null || getClass() != o.getClass()) { |
| 65 | return false; |
| 66 | } |
| 67 | DeviceBandwidthProfile that = (DeviceBandwidthProfile) o; |
| 68 | return devId.equals(that.devId) |
| 69 | && bwInfo.equals(that.bwInfo); |
| 70 | } |
| 71 | |
| 72 | @Override |
| 73 | public int hashCode() { |
| 74 | return Objects.hash(devId, bwInfo); |
| 75 | } |
| 76 | |
| 77 | @Override |
| 78 | public String toString() { |
| 79 | return com.google.common.base.MoreObjects.toStringHelper(this) |
| 80 | .add("devId", devId) |
| 81 | .add("bwInfo", bwInfo) |
| 82 | .toString(); |
| 83 | } |
| 84 | } |