blob: 5556736bb1fd3c0125b053b47d7a9eef90da3362 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.store.device.impl;
Yuta HIGUCHI9ee60f62014-10-09 10:00:01 -070017
18import java.util.Objects;
19
Brian O'Connorabafb502014-12-02 22:26:20 -080020import org.onosproject.net.DeviceId;
21import org.onosproject.net.provider.ProviderId;
Yuta HIGUCHI9ee60f62014-10-09 10:00:01 -070022
23import com.google.common.base.MoreObjects;
24
25/**
26 * Identifier for DeviceDesctiption from a Provider.
27 */
28public final class DeviceFragmentId {
29 public final ProviderId providerId;
30 public final DeviceId deviceId;
31
32 public DeviceFragmentId(DeviceId deviceId, ProviderId providerId) {
33 this.providerId = providerId;
34 this.deviceId = deviceId;
35 }
36
37 @Override
38 public int hashCode() {
39 return Objects.hash(providerId, deviceId);
40 }
41
42 @Override
43 public boolean equals(Object obj) {
44 if (this == obj) {
45 return true;
46 }
47 if (!(obj instanceof DeviceFragmentId)) {
48 return false;
49 }
50 DeviceFragmentId that = (DeviceFragmentId) obj;
51 return Objects.equals(this.deviceId, that.deviceId) &&
52 Objects.equals(this.providerId, that.providerId);
53 }
54
55 @Override
56 public String toString() {
57 return MoreObjects.toStringHelper(getClass())
58 .add("providerId", providerId)
59 .add("deviceId", deviceId)
60 .toString();
61 }
62
63 // for serializer
64 @SuppressWarnings("unused")
65 private DeviceFragmentId() {
66 this.providerId = null;
67 this.deviceId = null;
68 }
Yuta HIGUCHI5ec89f92014-10-12 01:01:43 -070069}