Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Laboratory |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.store.device.impl; |
Yuta HIGUCHI | 9ee60f6 | 2014-10-09 10:00:01 -0700 | [diff] [blame] | 17 | |
| 18 | import java.util.Objects; |
| 19 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 20 | import org.onosproject.net.DeviceId; |
| 21 | import org.onosproject.net.PortNumber; |
| 22 | import org.onosproject.net.provider.ProviderId; |
Yuta HIGUCHI | 9ee60f6 | 2014-10-09 10:00:01 -0700 | [diff] [blame] | 23 | |
| 24 | import com.google.common.base.MoreObjects; |
| 25 | |
| 26 | /** |
| 27 | * Identifier for PortDescription from a Provider. |
| 28 | */ |
| 29 | public final class PortFragmentId { |
| 30 | public final ProviderId providerId; |
| 31 | public final DeviceId deviceId; |
| 32 | public final PortNumber portNumber; |
| 33 | |
| 34 | public PortFragmentId(DeviceId deviceId, ProviderId providerId, |
| 35 | PortNumber portNumber) { |
| 36 | this.providerId = providerId; |
| 37 | this.deviceId = deviceId; |
| 38 | this.portNumber = portNumber; |
| 39 | } |
| 40 | |
| 41 | @Override |
| 42 | public int hashCode() { |
| 43 | return Objects.hash(providerId, deviceId, portNumber); |
Sho SHIMIZU | 9f614a4 | 2015-09-11 15:32:46 -0700 | [diff] [blame] | 44 | } |
Yuta HIGUCHI | 9ee60f6 | 2014-10-09 10:00:01 -0700 | [diff] [blame] | 45 | |
| 46 | @Override |
| 47 | public boolean equals(Object obj) { |
| 48 | if (this == obj) { |
| 49 | return true; |
| 50 | } |
| 51 | if (!(obj instanceof PortFragmentId)) { |
| 52 | return false; |
| 53 | } |
| 54 | PortFragmentId that = (PortFragmentId) obj; |
| 55 | return Objects.equals(this.deviceId, that.deviceId) && |
| 56 | Objects.equals(this.portNumber, that.portNumber) && |
| 57 | Objects.equals(this.providerId, that.providerId); |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public String toString() { |
| 62 | return MoreObjects.toStringHelper(getClass()) |
| 63 | .add("providerId", providerId) |
| 64 | .add("deviceId", deviceId) |
| 65 | .add("portNumber", portNumber) |
| 66 | .toString(); |
| 67 | } |
| 68 | |
| 69 | // for serializer |
| 70 | @SuppressWarnings("unused") |
| 71 | private PortFragmentId() { |
| 72 | this.providerId = null; |
| 73 | this.deviceId = null; |
| 74 | this.portNumber = null; |
| 75 | } |
Yuta HIGUCHI | 5ec89f9 | 2014-10-12 01:01:43 -0700 | [diff] [blame] | 76 | } |