Saurav Das | 4ce4596 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 1 | package org.onosproject.segmentrouting.grouphandler; |
| 2 | |
| 3 | import org.onosproject.net.DeviceId; |
| 4 | import org.onosproject.net.PortNumber; |
| 5 | import org.onosproject.net.flow.TrafficTreatment; |
| 6 | |
| 7 | import java.util.Objects; |
| 8 | |
| 9 | /** |
Charles Chan | e849c19 | 2016-01-11 18:28:54 -0800 | [diff] [blame^] | 10 | * 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 Das | 4ce4596 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 14 | */ |
| 15 | public class PortNextObjectiveStoreKey { |
| 16 | private final DeviceId deviceId; |
| 17 | private final PortNumber portNum; |
| 18 | private final TrafficTreatment treatment; |
| 19 | |
Charles Chan | e849c19 | 2016-01-11 18:28:54 -0800 | [diff] [blame^] | 20 | /** |
| 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 Das | 4ce4596 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 27 | 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 | } |