blob: aa5d5e1d91813c93153737b9834e4594377ccf3b [file] [log] [blame]
Aihua Guo1ce2dd12016-08-12 23:37:44 -04001/*
2 * Copyright 2016 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 */
16package org.onosproject.tetopology.management.api.link;
17
18import org.onosproject.tetopology.management.api.KeyId;
19
20import com.google.common.base.MoreObjects;
21import com.google.common.base.Objects;
22
23/**
24 * Representation of a link key or link reference.
25 */
26public class NetworkLinkKey {
27 private final KeyId networkId;
28 private final KeyId linkId;
29
30 /**
31 * Creates an instance of NetworkLinkKey.
32 *
33 * @param networkId network identifier
34 * @param linkId link identifier
35 */
36 public NetworkLinkKey(KeyId networkId, KeyId linkId) {
37 this.networkId = networkId;
38 this.linkId = linkId;
39 }
40
41 /**
42 * Returns the network identifier.
43 *
44 * @return network identifier
45 */
46 public KeyId networkId() {
47 return networkId;
48 }
49
50 /**
51 * Returns the link identifier.
52 *
53 * @return link identifier
54 */
55 public KeyId linkId() {
56 return linkId;
57 }
58
59 @Override
60 public int hashCode() {
61 return Objects.hashCode(networkId, linkId);
62 }
63
64 @Override
65 public boolean equals(Object object) {
66 if (this == object) {
67 return true;
68 }
69 if (object instanceof NetworkLinkKey) {
70 NetworkLinkKey that = (NetworkLinkKey) object;
71 return Objects.equal(this.networkId, that.networkId) &&
72 Objects.equal(this.linkId, that.linkId);
73 }
74 return false;
75 }
76
77 @Override
78 public String toString() {
79 return MoreObjects.toStringHelper(this)
80 .add("networkId", networkId)
81 .add("linkId", linkId)
82 .toString();
83 }
84
85}