blob: 9b02a6c2d560193d7a760eba2f8862154ee1e966 [file] [log] [blame]
Madan Jampanifc8aced2015-08-27 11:06:12 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Madan Jampanifc8aced2015-08-27 11:06:12 -07003 *
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 */
16package org.onosproject.store.device.impl;
17
18import java.util.Objects;
19
20import org.onosproject.net.DeviceId;
21import org.onosproject.net.PortNumber;
22import org.onosproject.net.provider.ProviderId;
23
24import com.google.common.base.MoreObjects;
25
26/**
27 * Key for PortDescriptions in ECDeviceStore.
28 */
29public class PortKey {
30 private final ProviderId providerId;
31 private final DeviceId deviceId;
32 private final PortNumber portNumber;
33
34 public PortKey(ProviderId providerId, DeviceId deviceId, PortNumber portNumber) {
35 this.providerId = providerId;
36 this.deviceId = deviceId;
37 this.portNumber = portNumber;
38 }
39
40 public ProviderId providerId() {
41 return providerId;
42 }
43
44 public DeviceId deviceId() {
45 return deviceId;
46 }
47
48 public PortNumber portNumber() {
49 return portNumber;
50 }
51
52 @Override
53 public int hashCode() {
54 return Objects.hash(providerId, deviceId, portNumber);
55 }
56
57 @Override
58 public boolean equals(Object obj) {
59 if (this == obj) {
60 return true;
61 }
62 if (!(obj instanceof PortKey)) {
63 return false;
64 }
65 PortKey that = (PortKey) obj;
66 return Objects.equals(this.deviceId, that.deviceId) &&
67 Objects.equals(this.providerId, that.providerId) &&
68 Objects.equals(this.portNumber, that.portNumber);
69 }
70
71 @Override
72 public String toString() {
73 return MoreObjects.toStringHelper(getClass())
74 .add("providerId", providerId)
75 .add("deviceId", deviceId)
76 .add("portNumber", portNumber)
77 .toString();
78 }
79}