blob: d935946dcc673a8d6ce245fe1f4e2185b8ddc5cf [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 HIGUCHI5fa3dc02014-10-15 17:08:13 -070016package org.onlab.onos.store.host.impl;
17
18import java.util.Objects;
19
20import org.onlab.onos.net.HostId;
21import org.onlab.onos.net.provider.ProviderId;
22
23import com.google.common.base.MoreObjects;
24
25/**
26 * Identifier for HostDescription from a Provider.
27 */
28public final class HostFragmentId {
29 public final ProviderId providerId;
30 public final HostId hostId;
31
32 public HostFragmentId(HostId hostId, ProviderId providerId) {
33 this.providerId = providerId;
34 this.hostId = hostId;
35 }
36
37 public HostId hostId() {
38 return hostId;
39 }
40
41 public ProviderId providerId() {
42 return providerId;
43 }
44
45 @Override
46 public int hashCode() {
47 return Objects.hash(providerId, hostId);
48 }
49
50 @Override
51 public boolean equals(Object obj) {
52 if (this == obj) {
53 return true;
54 }
55 if (!(obj instanceof HostFragmentId)) {
56 return false;
57 }
58 HostFragmentId that = (HostFragmentId) obj;
59 return Objects.equals(this.hostId, that.hostId) &&
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("hostId", hostId)
68 .toString();
69 }
70
71 // for serializer
72 @SuppressWarnings("unused")
73 private HostFragmentId() {
74 this.providerId = null;
75 this.hostId = null;
76 }
77}