Saurav Das | 0e99e2b | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 1 | package org.onosproject.segmentrouting; |
| 2 | |
| 3 | import java.util.Objects; |
| 4 | |
| 5 | import org.onlab.packet.Ip4Prefix; |
| 6 | import org.onosproject.net.DeviceId; |
| 7 | |
| 8 | /** |
Charles Chan | e849c19 | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 9 | * Key of assigned VLAN ID store. |
Saurav Das | 0e99e2b | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 10 | */ |
| 11 | public class SubnetAssignedVidStoreKey { |
| 12 | private final DeviceId deviceId; |
| 13 | private final Ip4Prefix subnet; |
| 14 | |
Charles Chan | e849c19 | 2016-01-11 18:28:54 -0800 | [diff] [blame] | 15 | /** |
| 16 | * Constructs the key of per subnet VLAN ID store. |
| 17 | * |
| 18 | * @param deviceId device ID of the VLAN cross-connection |
| 19 | * @param subnet subnet information |
| 20 | */ |
Saurav Das | 0e99e2b | 2015-10-28 12:39:42 -0700 | [diff] [blame] | 21 | public SubnetAssignedVidStoreKey(DeviceId deviceId, Ip4Prefix subnet) { |
| 22 | this.deviceId = deviceId; |
| 23 | this.subnet = subnet; |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * Returns the device identification used to create this key. |
| 28 | * |
| 29 | * @return the device identifier |
| 30 | */ |
| 31 | public DeviceId deviceId() { |
| 32 | return deviceId; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Returns the subnet information used to create this key. |
| 37 | * |
| 38 | * @return the subnet |
| 39 | */ |
| 40 | public Ip4Prefix subnet() { |
| 41 | return subnet; |
| 42 | } |
| 43 | |
| 44 | @Override |
| 45 | public boolean equals(Object o) { |
| 46 | if (this == o) { |
| 47 | return true; |
| 48 | } |
| 49 | if (!(o instanceof SubnetAssignedVidStoreKey)) { |
| 50 | return false; |
| 51 | } |
| 52 | SubnetAssignedVidStoreKey that = |
| 53 | (SubnetAssignedVidStoreKey) o; |
| 54 | return (Objects.equals(this.deviceId, that.deviceId) && |
| 55 | Objects.equals(this.subnet, that.subnet)); |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public int hashCode() { |
| 60 | int result = 17; |
| 61 | result = 31 * result + Objects.hashCode(deviceId) |
| 62 | + Objects.hashCode(subnet); |
| 63 | return result; |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public String toString() { |
| 68 | return "Device: " + deviceId + " Subnet: " + subnet; |
| 69 | } |
| 70 | |
| 71 | } |