Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 0947d7e | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [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 | |
Charles Chan | 1eaf480 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 17 | package org.onosproject.segmentrouting.storekey; |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 18 | |
| 19 | import org.onlab.packet.VlanId; |
| 20 | import org.onosproject.net.DeviceId; |
| 21 | |
| 22 | import java.util.Objects; |
| 23 | |
| 24 | /** |
| 25 | * Key of VLAN cross-connect next objective store. |
| 26 | */ |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 27 | public class XConnectStoreKey { |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 28 | private final DeviceId deviceId; |
| 29 | private final VlanId vlanId; |
| 30 | |
| 31 | /** |
| 32 | * Constructs the key of cross-connect next objective store. |
| 33 | * |
| 34 | * @param deviceId device ID of the VLAN cross-connection |
| 35 | * @param vlanId VLAN ID of the VLAN cross-connection |
| 36 | */ |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 37 | public XConnectStoreKey(DeviceId deviceId, VlanId vlanId) { |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 38 | this.deviceId = deviceId; |
| 39 | this.vlanId = vlanId; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Returns the device ID of this key. |
| 44 | * |
| 45 | * @return device ID |
| 46 | */ |
| 47 | public DeviceId deviceId() { |
| 48 | return this.deviceId; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Returns the VLAN ID of this key. |
| 53 | * |
| 54 | * @return VLAN ID |
| 55 | */ |
| 56 | public VlanId vlanId() { |
| 57 | return this.vlanId; |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public boolean equals(Object o) { |
| 62 | if (this == o) { |
| 63 | return true; |
| 64 | } |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 65 | if (!(o instanceof XConnectStoreKey)) { |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 66 | return false; |
| 67 | } |
Charles Chan | 82f1997 | 2016-05-17 13:13:55 -0700 | [diff] [blame] | 68 | XConnectStoreKey that = |
| 69 | (XConnectStoreKey) o; |
Charles Chan | b7f75ac | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 70 | return (Objects.equals(this.deviceId, that.deviceId) && |
| 71 | Objects.equals(this.vlanId, that.vlanId)); |
| 72 | } |
| 73 | |
| 74 | // The list of neighbor ids and label are used for comparison. |
| 75 | @Override |
| 76 | public int hashCode() { |
| 77 | return Objects.hash(deviceId, vlanId); |
| 78 | } |
| 79 | |
| 80 | @Override |
| 81 | public String toString() { |
| 82 | return "Device: " + deviceId + " VlanId: " + vlanId; |
| 83 | } |
| 84 | } |