Tunahan Sezen | 03e5527 | 2020-04-18 09:18:53 +0000 | [diff] [blame] | 1 | /* |
Joey Armstrong | 53fcac2 | 2023-01-11 13:25:01 -0500 | [diff] [blame^] | 2 | * Copyright 2017-2023 Open Networking Foundation (ONF) and the ONF Contributors |
Tunahan Sezen | 03e5527 | 2020-04-18 09:18:53 +0000 | [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 | package org.opencord.maclearner.api; |
| 17 | |
| 18 | import org.onlab.packet.VlanId; |
| 19 | import org.onosproject.net.DeviceId; |
| 20 | import org.onosproject.net.PortNumber; |
| 21 | |
| 22 | import java.util.Objects; |
| 23 | |
| 24 | /** |
| 25 | * Key of Mac Address Map. |
| 26 | */ |
| 27 | public class MacLearnerKey { |
| 28 | |
| 29 | private DeviceId deviceId; |
| 30 | private PortNumber portNumber; |
| 31 | private VlanId vlanId; |
| 32 | |
| 33 | public DeviceId getDeviceId() { |
| 34 | return deviceId; |
| 35 | } |
| 36 | |
| 37 | public void setDeviceId(DeviceId deviceId) { |
| 38 | this.deviceId = deviceId; |
| 39 | } |
| 40 | |
| 41 | public PortNumber getPortNumber() { |
| 42 | return portNumber; |
| 43 | } |
| 44 | |
| 45 | public void setPortNumber(PortNumber portNumber) { |
| 46 | this.portNumber = portNumber; |
| 47 | } |
| 48 | |
| 49 | public VlanId getVlanId() { |
| 50 | return vlanId; |
| 51 | } |
| 52 | |
| 53 | public void setVlanId(VlanId vlanId) { |
| 54 | this.vlanId = vlanId; |
| 55 | } |
| 56 | |
| 57 | public MacLearnerKey(DeviceId deviceId, PortNumber portNumber, VlanId vlanId) { |
| 58 | this.deviceId = deviceId; |
| 59 | this.portNumber = portNumber; |
| 60 | this.vlanId = vlanId; |
| 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public String toString() { |
| 65 | return "MacLearnerKey{" + |
| 66 | "deviceId=" + deviceId + |
| 67 | ", portNumber=" + portNumber + |
| 68 | ", vlanId=" + vlanId + |
| 69 | '}'; |
| 70 | } |
| 71 | |
| 72 | @Override |
| 73 | public boolean equals(Object o) { |
| 74 | if (this == o) { |
| 75 | return true; |
| 76 | } |
| 77 | if (o == null || getClass() != o.getClass()) { |
| 78 | return false; |
| 79 | } |
| 80 | MacLearnerKey that = (MacLearnerKey) o; |
| 81 | return Objects.equals(deviceId, that.deviceId) && |
| 82 | Objects.equals(portNumber, that.portNumber) && |
| 83 | Objects.equals(vlanId, that.vlanId); |
| 84 | } |
| 85 | |
| 86 | @Override |
| 87 | public int hashCode() { |
| 88 | return Objects.hash(deviceId, portNumber, vlanId); |
| 89 | } |
| 90 | |
| 91 | } |