blob: 67616f258fec85bbe228a701240cc7e1ee81d3f3 [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.provider.ProviderId;
22
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}