blob: fdf28dfac5127905d36446cbd132b024c11f3924 [file] [log] [blame]
Brian O'Connor7cbbbb72016-04-09 02:13:23 -07001/*
Charles Chand2990362016-04-18 13:44:03 -07002 * Copyright 2016-present Open Networking Laboratory
Brian O'Connor7cbbbb72016-04-09 02:13:23 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Charles Chand2990362016-04-18 13:44:03 -070016package org.onosproject.segmentrouting.storekey;
Saurav Das4ce45962015-11-24 23:21:05 -080017
18import org.onosproject.net.DeviceId;
19import org.onosproject.net.PortNumber;
20import org.onosproject.net.flow.TrafficTreatment;
21
22import java.util.Objects;
23
24/**
Charles Chane849c192016-01-11 18:28:54 -080025 * Key of Device/Port to NextObjective store.
26 *
27 * Since there can be multiple next objectives to the same physical port,
28 * we differentiate between them by including the treatment in the key.
Saurav Das4ce45962015-11-24 23:21:05 -080029 */
30public class PortNextObjectiveStoreKey {
31 private final DeviceId deviceId;
32 private final PortNumber portNum;
33 private final TrafficTreatment treatment;
34
Charles Chane849c192016-01-11 18:28:54 -080035 /**
36 * Constructs the key of port next objective store.
37 *
38 * @param deviceId device ID
39 * @param portNum port number
40 * @param treatment treatment that will be applied to the interface
41 */
Saurav Das4ce45962015-11-24 23:21:05 -080042 public PortNextObjectiveStoreKey(DeviceId deviceId, PortNumber portNum,
43 TrafficTreatment treatment) {
44 this.deviceId = deviceId;
45 this.portNum = portNum;
46 this.treatment = treatment;
47 }
48
49 /**
50 * Gets device id in this PortNextObjectiveStoreKey.
51 *
52 * @return device id
53 */
54 public DeviceId deviceId() {
55 return deviceId;
56 }
57
58 /**
59 * Gets port information in this PortNextObjectiveStoreKey.
60 *
61 * @return port information
62 */
63 public PortNumber portNumber() {
64 return portNum;
65 }
66
67 /**
68 * Gets treatment information in this PortNextObjectiveStoreKey.
69 *
70 * @return treatment information
71 */
72 public TrafficTreatment treatment() {
73 return treatment;
74 }
75
76 @Override
77 public boolean equals(Object o) {
78 if (this == o) {
79 return true;
80 }
81 if (!(o instanceof PortNextObjectiveStoreKey)) {
82 return false;
83 }
84 PortNextObjectiveStoreKey that =
85 (PortNextObjectiveStoreKey) o;
86 return (Objects.equals(this.deviceId, that.deviceId) &&
87 Objects.equals(this.portNum, that.portNum) &&
88 Objects.equals(this.treatment, that.treatment));
89 }
90
91 @Override
92 public int hashCode() {
93 return Objects.hash(deviceId, portNum, treatment);
94 }
95
96 @Override
97 public String toString() {
98 return "Device: " + deviceId + " Port: " + portNum + " Treatment: " + treatment;
99 }
100}