Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package org.onosproject.p4runtime.api; |
| 18 | |
| 19 | import com.google.common.annotations.Beta; |
| 20 | import com.google.common.base.MoreObjects; |
| 21 | import com.google.common.base.Objects; |
| 22 | import org.onosproject.net.DeviceId; |
Carmelo Cascone | 87892e2 | 2017-11-13 16:01:29 -0800 | [diff] [blame^] | 23 | import org.onosproject.net.pi.model.PiActionProfileId; |
Yi Tseng | 82512da | 2017-08-16 19:46:36 -0700 | [diff] [blame] | 24 | import org.onosproject.net.pi.runtime.PiActionGroupId; |
| 25 | |
| 26 | /** |
| 27 | * Class containing the reference for a group in P4Runtime. |
| 28 | */ |
| 29 | @Beta |
| 30 | public 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 | } |