blob: 74398c1c75550cb8e69b7a8790e8749c6a9ca272 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 Open Networking Laboratory
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 */
Yuta HIGUCHI5ec89f92014-10-12 01:01:43 -070016package org.onlab.onos.store.device.impl;
Yuta HIGUCHI9ee60f62014-10-09 10:00:01 -070017
18import java.util.Objects;
19
20import org.onlab.onos.net.DeviceId;
21import org.onlab.onos.net.PortNumber;
22import org.onlab.onos.net.provider.ProviderId;
23
24import com.google.common.base.MoreObjects;
25
26/**
27 * Identifier for PortDescription from a Provider.
28 */
29public 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);
44 };
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 HIGUCHI5ec89f92014-10-12 01:01:43 -070076}