Brian O'Connor | 7cbbbb7 | 2016-04-09 02:13:23 -0700 | [diff] [blame] | 1 | /* |
Charles Chan | d299036 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Brian O'Connor | 7cbbbb7 | 2016-04-09 02:13:23 -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 | */ |
Charles Chan | d299036 | 2016-04-18 13:44:03 -0700 | [diff] [blame] | 16 | package org.onosproject.segmentrouting.storekey; |
Saurav Das | 0e99e2b | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 17 | |
| 18 | import java.util.Objects; |
| 19 | |
| 20 | import org.onlab.packet.Ip4Prefix; |
| 21 | import org.onosproject.net.DeviceId; |
| 22 | |
| 23 | /** |
Charles Chan | e849c19 | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 24 | * Key of assigned VLAN ID store. |
Saurav Das | 0e99e2b | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 25 | */ |
| 26 | public class SubnetAssignedVidStoreKey { |
| 27 | private final DeviceId deviceId; |
| 28 | private final Ip4Prefix subnet; |
| 29 | |
Charles Chan | e849c19 | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 30 | /** |
| 31 | * Constructs the key of per subnet VLAN ID store. |
| 32 | * |
| 33 | * @param deviceId device ID of the VLAN cross-connection |
| 34 | * @param subnet subnet information |
| 35 | */ |
Saurav Das | 0e99e2b | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 36 | public SubnetAssignedVidStoreKey(DeviceId deviceId, Ip4Prefix subnet) { |
| 37 | this.deviceId = deviceId; |
| 38 | this.subnet = subnet; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Returns the device identification used to create this key. |
| 43 | * |
| 44 | * @return the device identifier |
| 45 | */ |
| 46 | public DeviceId deviceId() { |
| 47 | return deviceId; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Returns the subnet information used to create this key. |
| 52 | * |
| 53 | * @return the subnet |
| 54 | */ |
| 55 | public Ip4Prefix subnet() { |
| 56 | return subnet; |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public boolean equals(Object o) { |
| 61 | if (this == o) { |
| 62 | return true; |
| 63 | } |
| 64 | if (!(o instanceof SubnetAssignedVidStoreKey)) { |
| 65 | return false; |
| 66 | } |
| 67 | SubnetAssignedVidStoreKey that = |
| 68 | (SubnetAssignedVidStoreKey) o; |
| 69 | return (Objects.equals(this.deviceId, that.deviceId) && |
| 70 | Objects.equals(this.subnet, that.subnet)); |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | public int hashCode() { |
| 75 | int result = 17; |
| 76 | result = 31 * result + Objects.hashCode(deviceId) |
| 77 | + Objects.hashCode(subnet); |
| 78 | return result; |
| 79 | } |
| 80 | |
| 81 | @Override |
| 82 | public String toString() { |
| 83 | return "Device: " + deviceId + " Subnet: " + subnet; |
| 84 | } |
| 85 | |
| 86 | } |