blob: 55c9e6175fd65e5ab520fbf7acceb40568453e38 [file] [log] [blame]
Yi Tseng82512da2017-08-16 19:46:36 -07001/*
2 * Copyright 2017-present Open Networking Foundation
3 *
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 */
16
17package org.onosproject.p4runtime.api;
18
19import com.google.common.annotations.Beta;
20import com.google.common.base.MoreObjects;
21import com.google.common.base.Objects;
22import org.onosproject.net.DeviceId;
Carmelo Cascone87892e22017-11-13 16:01:29 -080023import org.onosproject.net.pi.model.PiActionProfileId;
Yi Tseng82512da2017-08-16 19:46:36 -070024import org.onosproject.net.pi.runtime.PiActionGroupId;
25
26/**
27 * Class containing the reference for a group in P4Runtime.
28 */
29@Beta
30public final class P4RuntimeGroupReference {
31 private final DeviceId deviceId;
32 private final PiActionProfileId piActionProfileId;
33 private final PiActionGroupId groupId;
34
35 /**
36 * Creates P4 runtime group reference.
37 *
38 * @param deviceId the device id of group
39 * @param piActionProfileId the action profile id
40 * @param groupId the group Id of group
41 */
42 public P4RuntimeGroupReference(DeviceId deviceId, PiActionProfileId piActionProfileId,
43 PiActionGroupId groupId) {
44 this.deviceId = deviceId;
45 this.piActionProfileId = piActionProfileId;
46 this.groupId = groupId;
47 }
48
49 /**
50 * Gets device id of this group.
51 *
52 * @return the device id
53 */
54 public DeviceId deviceId() {
55 return deviceId;
56 }
57
58 /**
59 * Gets action profile id of this group.
60 *
61 * @return the action profile id
62 */
63 public PiActionProfileId actionProfileId() {
64 return piActionProfileId;
65 }
66
67 /**
68 * Gets group id of this group.
69 *
70 * @return group id
71 */
72 public PiActionGroupId groupId() {
73 return groupId;
74 }
75
76 @Override
77 public boolean equals(Object o) {
78 if (this == o) {
79 return true;
80 }
81 if (o == null || getClass() != o.getClass()) {
82 return false;
83 }
84 P4RuntimeGroupReference that = (P4RuntimeGroupReference) o;
85 return Objects.equal(deviceId, that.deviceId) &&
86 Objects.equal(piActionProfileId, that.piActionProfileId) &&
87 Objects.equal(groupId, that.groupId);
88 }
89
90 @Override
91 public int hashCode() {
92 return Objects.hashCode(deviceId, piActionProfileId, groupId);
93 }
94
95 @Override
96 public String toString() {
97 return MoreObjects.toStringHelper(this)
98 .add("deviceId", deviceId)
99 .add("piActionProfileId", piActionProfileId)
100 .add("groupId", groupId)
101 .toString();
102 }
103}