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 | /** |
| 10 | * Class definition of Key for Device/Port to NextObjective store. Since there |
| 11 | * can be multiple next objectives to the same physical port, we differentiate |
| 12 | * between them by including the treatment in the key. |
| 13 | */ |
| 14 | public class PortNextObjectiveStoreKey { |
| 15 | private final DeviceId deviceId; |
| 16 | private final PortNumber portNum; |
| 17 | private final TrafficTreatment treatment; |
| 18 | |
| 19 | public PortNextObjectiveStoreKey(DeviceId deviceId, PortNumber portNum, |
| 20 | TrafficTreatment treatment) { |
| 21 | this.deviceId = deviceId; |
| 22 | this.portNum = portNum; |
| 23 | this.treatment = treatment; |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * Gets device id in this PortNextObjectiveStoreKey. |
| 28 | * |
| 29 | * @return device id |
| 30 | */ |
| 31 | public DeviceId deviceId() { |
| 32 | return deviceId; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Gets port information in this PortNextObjectiveStoreKey. |
| 37 | * |
| 38 | * @return port information |
| 39 | */ |
| 40 | public PortNumber portNumber() { |
| 41 | return portNum; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Gets treatment information in this PortNextObjectiveStoreKey. |
| 46 | * |
| 47 | * @return treatment information |
| 48 | */ |
| 49 | public TrafficTreatment treatment() { |
| 50 | return treatment; |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public boolean equals(Object o) { |
| 55 | if (this == o) { |
| 56 | return true; |
| 57 | } |
| 58 | if (!(o instanceof PortNextObjectiveStoreKey)) { |
| 59 | return false; |
| 60 | } |
| 61 | PortNextObjectiveStoreKey that = |
| 62 | (PortNextObjectiveStoreKey) o; |
| 63 | return (Objects.equals(this.deviceId, that.deviceId) && |
| 64 | Objects.equals(this.portNum, that.portNum) && |
| 65 | Objects.equals(this.treatment, that.treatment)); |
| 66 | } |
| 67 | |
| 68 | @Override |
| 69 | public int hashCode() { |
| 70 | return Objects.hash(deviceId, portNum, treatment); |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | public String toString() { |
| 75 | return "Device: " + deviceId + " Port: " + portNum + " Treatment: " + treatment; |
| 76 | } |
| 77 | } |