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 | |
Pier Ventre | 10bd8d1 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 18 | import org.onlab.packet.IpPrefix; |
Saurav Das | 0e99e2b | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 19 | import org.onosproject.net.DeviceId; |
| 20 | |
Pier Ventre | 10bd8d1 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 21 | import java.util.Objects; |
| 22 | |
Saurav Das | 0e99e2b | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 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; |
Pier Ventre | 10bd8d1 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 28 | private final IpPrefix subnet; |
Saurav Das | 0e99e2b | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 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 | */ |
Pier Ventre | 10bd8d1 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 36 | public SubnetAssignedVidStoreKey(DeviceId deviceId, IpPrefix subnet) { |
Saurav Das | 0e99e2b | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 37 | this.deviceId = deviceId; |
| 38 | this.subnet = subnet; |
| 39 | } |
| 40 | |
| 41 | /** |
Pier Ventre | f4b5fce | 2016-11-28 16:48:06 -0800 | [diff] [blame] | 42 | * Default constructor for Kryo. |
| 43 | */ |
| 44 | protected SubnetAssignedVidStoreKey() { |
| 45 | this.deviceId = null; |
| 46 | this.subnet = null; |
| 47 | } |
| 48 | |
| 49 | /** |
Saurav Das | 0e99e2b | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 50 | * Returns the device identification used to create this key. |
| 51 | * |
| 52 | * @return the device identifier |
| 53 | */ |
| 54 | public DeviceId deviceId() { |
| 55 | return deviceId; |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Returns the subnet information used to create this key. |
| 60 | * |
| 61 | * @return the subnet |
| 62 | */ |
Pier Ventre | 10bd8d1 | 2016-11-26 21:05:22 -0800 | [diff] [blame] | 63 | public IpPrefix subnet() { |
Saurav Das | 0e99e2b | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 64 | return subnet; |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public boolean equals(Object o) { |
| 69 | if (this == o) { |
| 70 | return true; |
| 71 | } |
| 72 | if (!(o instanceof SubnetAssignedVidStoreKey)) { |
| 73 | return false; |
| 74 | } |
| 75 | SubnetAssignedVidStoreKey that = |
| 76 | (SubnetAssignedVidStoreKey) o; |
| 77 | return (Objects.equals(this.deviceId, that.deviceId) && |
| 78 | Objects.equals(this.subnet, that.subnet)); |
| 79 | } |
| 80 | |
| 81 | @Override |
| 82 | public int hashCode() { |
| 83 | int result = 17; |
| 84 | result = 31 * result + Objects.hashCode(deviceId) |
| 85 | + Objects.hashCode(subnet); |
| 86 | return result; |
| 87 | } |
| 88 | |
| 89 | @Override |
| 90 | public String toString() { |
| 91 | return "Device: " + deviceId + " Subnet: " + subnet; |
| 92 | } |
| 93 | |
| 94 | } |