blob: b721d0ed53ea7ea54a4158c97618184339601e4e [file] [log] [blame]
Saurav Das0e99e2b2015-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/**
Charles Chane849c192016-01-11 18:28:54 -08009 * Key of assigned VLAN ID store.
Saurav Das0e99e2b2015-10-28 12:39:42 -070010 */
11public class SubnetAssignedVidStoreKey {
12 private final DeviceId deviceId;
13 private final Ip4Prefix subnet;
14
Charles Chane849c192016-01-11 18:28:54 -080015 /**
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 Das0e99e2b2015-10-28 12:39:42 -070021 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}