Carmelo Cascone | 5813681 | 2018-07-19 03:40:16 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-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.net.pi.runtime; |
| 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; |
| 23 | |
| 24 | /** |
| 25 | * Global identifier of a PI multicast group entry applied to the packet |
| 26 | * replication engine of a device, uniquely defined by a device ID, and group |
| 27 | * ID. |
| 28 | */ |
| 29 | @Beta |
| 30 | public final class PiMulticastGroupEntryHandle extends PiHandle<PiMulticastGroupEntry> { |
| 31 | |
| 32 | private PiMulticastGroupEntryHandle(DeviceId deviceId, PiMulticastGroupEntry entry) { |
| 33 | super(deviceId, entry); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Creates a new handle for the given device ID and PI multicast group |
| 38 | * entry. |
| 39 | * |
| 40 | * @param deviceId device ID |
| 41 | * @param entry PI multicast group entry |
| 42 | * @return PI multicast group entry handle |
| 43 | */ |
| 44 | public static PiMulticastGroupEntryHandle of(DeviceId deviceId, |
| 45 | PiMulticastGroupEntry entry) { |
| 46 | return new PiMulticastGroupEntryHandle(deviceId, entry); |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | public int hashCode() { |
| 51 | return Objects.hashCode(deviceId(), piEntity().groupId()); |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public boolean equals(Object o) { |
| 56 | if (this == o) { |
| 57 | return true; |
| 58 | } |
| 59 | if (o == null || getClass() != o.getClass()) { |
| 60 | return false; |
| 61 | } |
| 62 | PiMulticastGroupEntryHandle that = (PiMulticastGroupEntryHandle) o; |
| 63 | return Objects.equal(deviceId(), that.deviceId()) && |
| 64 | Objects.equal(piEntity().groupId(), that.piEntity().groupId()); |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public String toString() { |
| 69 | return MoreObjects.toStringHelper(this) |
| 70 | .add("deviceId", deviceId()) |
| 71 | .add("groupId", piEntity().groupId()) |
| 72 | .toString(); |
| 73 | } |
| 74 | } |