blob: 082e4578f6595e2664263608afe793112e40bc10 [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.link.impl;
Madan Jampania97e8202014-10-10 17:01:33 -070017
18import java.util.Objects;
19
Brian O'Connorabafb502014-12-02 22:26:20 -080020import org.onosproject.net.LinkKey;
21import org.onosproject.net.provider.ProviderId;
Madan Jampania97e8202014-10-10 17:01:33 -070022
23import com.google.common.base.MoreObjects;
24
25/**
26 * Identifier for LinkDescription from a Provider.
27 */
28public final class LinkFragmentId {
29 public final ProviderId providerId;
30 public final LinkKey linkKey;
31
32 public LinkFragmentId(LinkKey linkKey, ProviderId providerId) {
33 this.providerId = providerId;
34 this.linkKey = linkKey;
35 }
36
37 public LinkKey linkKey() {
38 return linkKey;
39 }
40
41 public ProviderId providerId() {
42 return providerId;
43 }
44
45 @Override
46 public int hashCode() {
47 return Objects.hash(providerId, linkKey);
48 }
49
50 @Override
51 public boolean equals(Object obj) {
52 if (this == obj) {
53 return true;
54 }
55 if (!(obj instanceof LinkFragmentId)) {
56 return false;
57 }
58 LinkFragmentId that = (LinkFragmentId) obj;
59 return Objects.equals(this.linkKey, that.linkKey) &&
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("linkKey", linkKey)
68 .toString();
69 }
70
71 // for serializer
72 @SuppressWarnings("unused")
73 private LinkFragmentId() {
74 this.providerId = null;
75 this.linkKey = null;
76 }
77}