blob: ec25ec34a83c700fa580f459d6126a66908329b3 [file] [log] [blame]
Saurav Das4ce45962015-11-24 23:21:05 -08001package org.onosproject.segmentrouting.grouphandler;
2
3import org.onosproject.net.DeviceId;
4import org.onosproject.net.PortNumber;
5import org.onosproject.net.flow.TrafficTreatment;
6
7import java.util.Objects;
8
9/**
Charles Chane849c192016-01-11 18:28:54 -080010 * Key of Device/Port to NextObjective store.
11 *
12 * Since there can be multiple next objectives to the same physical port,
13 * we differentiate between them by including the treatment in the key.
Saurav Das4ce45962015-11-24 23:21:05 -080014 */
15public class PortNextObjectiveStoreKey {
16 private final DeviceId deviceId;
17 private final PortNumber portNum;
18 private final TrafficTreatment treatment;
19
Charles Chane849c192016-01-11 18:28:54 -080020 /**
21 * Constructs the key of port next objective store.
22 *
23 * @param deviceId device ID
24 * @param portNum port number
25 * @param treatment treatment that will be applied to the interface
26 */
Saurav Das4ce45962015-11-24 23:21:05 -080027 public PortNextObjectiveStoreKey(DeviceId deviceId, PortNumber portNum,
28 TrafficTreatment treatment) {
29 this.deviceId = deviceId;
30 this.portNum = portNum;
31 this.treatment = treatment;
32 }
33
34 /**
35 * Gets device id in this PortNextObjectiveStoreKey.
36 *
37 * @return device id
38 */
39 public DeviceId deviceId() {
40 return deviceId;
41 }
42
43 /**
44 * Gets port information in this PortNextObjectiveStoreKey.
45 *
46 * @return port information
47 */
48 public PortNumber portNumber() {
49 return portNum;
50 }
51
52 /**
53 * Gets treatment information in this PortNextObjectiveStoreKey.
54 *
55 * @return treatment information
56 */
57 public TrafficTreatment treatment() {
58 return treatment;
59 }
60
61 @Override
62 public boolean equals(Object o) {
63 if (this == o) {
64 return true;
65 }
66 if (!(o instanceof PortNextObjectiveStoreKey)) {
67 return false;
68 }
69 PortNextObjectiveStoreKey that =
70 (PortNextObjectiveStoreKey) o;
71 return (Objects.equals(this.deviceId, that.deviceId) &&
72 Objects.equals(this.portNum, that.portNum) &&
73 Objects.equals(this.treatment, that.treatment));
74 }
75
76 @Override
77 public int hashCode() {
78 return Objects.hash(deviceId, portNum, treatment);
79 }
80
81 @Override
82 public String toString() {
83 return "Device: " + deviceId + " Port: " + portNum + " Treatment: " + treatment;
84 }
85}