blob: 84b44c97f23bab22a784a8bd23f4531dfc68e721 [file] [log] [blame]
Saurav Das7c305372015-10-28 12:39:42 -07001package org.onosproject.segmentrouting;
2
3import java.util.Objects;
4
5import org.onlab.packet.Ip4Prefix;
6import org.onosproject.net.DeviceId;
7
8/**
9 * Class definition for key used to map per device subnets to assigned Vlan ids.
10 *
11 */
12public class SubnetAssignedVidStoreKey {
13 private final DeviceId deviceId;
14 private final Ip4Prefix subnet;
15
16 public SubnetAssignedVidStoreKey(DeviceId deviceId, Ip4Prefix subnet) {
17 this.deviceId = deviceId;
18 this.subnet = subnet;
19 }
20
21 /**
22 * Returns the device identification used to create this key.
23 *
24 * @return the device identifier
25 */
26 public DeviceId deviceId() {
27 return deviceId;
28 }
29
30 /**
31 * Returns the subnet information used to create this key.
32 *
33 * @return the subnet
34 */
35 public Ip4Prefix subnet() {
36 return subnet;
37 }
38
39 @Override
40 public boolean equals(Object o) {
41 if (this == o) {
42 return true;
43 }
44 if (!(o instanceof SubnetAssignedVidStoreKey)) {
45 return false;
46 }
47 SubnetAssignedVidStoreKey that =
48 (SubnetAssignedVidStoreKey) o;
49 return (Objects.equals(this.deviceId, that.deviceId) &&
50 Objects.equals(this.subnet, that.subnet));
51 }
52
53 @Override
54 public int hashCode() {
55 int result = 17;
56 result = 31 * result + Objects.hashCode(deviceId)
57 + Objects.hashCode(subnet);
58 return result;
59 }
60
61 @Override
62 public String toString() {
63 return "Device: " + deviceId + " Subnet: " + subnet;
64 }
65
66}