blob: 7d8f73ef5a49c48530e1c438d2d0a4fd6a52a677 [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.provider.ProviderId;
22
23import com.google.common.base.MoreObjects;
24
25/**
26 * Key for DeviceDescriptions in ECDeviceStore.
27 */
28public class DeviceKey {
29 private final ProviderId providerId;
30 private final DeviceId deviceId;
31
32 public DeviceKey(ProviderId providerId, DeviceId deviceId) {
33 this.providerId = providerId;
34 this.deviceId = deviceId;
35 }
36
37 public ProviderId providerId() {
38 return providerId;
39 }
40
41 public DeviceId deviceId() {
42 return deviceId;
43 }
44
45 @Override
46 public int hashCode() {
47 return Objects.hash(providerId, deviceId);
48 }
49
50 @Override
51 public boolean equals(Object obj) {
52 if (this == obj) {
53 return true;
54 }
55 if (!(obj instanceof DeviceKey)) {
56 return false;
57 }
58 DeviceKey that = (DeviceKey) obj;
59 return Objects.equals(this.deviceId, that.deviceId) &&
60 Objects.equals(this.providerId, that.providerId);
61 }
62
63 @Override
64 public String toString() {
65 return MoreObjects.toStringHelper(getClass())
66 .add("providerId", providerId)
67 .add("deviceId", deviceId)
68 .toString();
69 }
70}