blob: 5616147ff911bb8a6d933731204b73250a05c4bf [file] [log] [blame]
Henry Yu4b4a7eb2016-11-09 20:07:53 -05001/*
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 com.google.common.base.MoreObjects;
19import com.google.common.base.Objects;
20
21/**
22 * Representation of the TE link TP (i.e., TE termination point) Key in
23 * the scope of a TE node.
24 */
25public final class TeLinkTpKey {
26 private final long teNodeId;
27 private final long teLinkTpId;
28
29 /**
30 * Creates a TE link TP key.
31 *
32 * @param teNodeId TE Node identifier
33 * @param teLinkTpId TE Link termination point identifier
34 */
35 public TeLinkTpKey(long teNodeId, long teLinkTpId) {
36 this.teNodeId = teNodeId;
37 this.teLinkTpId = teLinkTpId;
38 }
39
40 /**
41 * Returns the TE Node identifier.
42 *
43 * @return the TE node id
44 */
45 public long teNodeId() {
46 return teNodeId;
47 }
48
49 /**
50 * Returns the TE link termination point identifier.
51 *
52 * @return the TE link TP id
53 */
54 public long teLinkTpId() {
55 return teLinkTpId;
56 }
57
58 @Override
59 public int hashCode() {
60 return Objects.hashCode(teNodeId, teLinkTpId);
61 }
62
63 @Override
64 public boolean equals(Object object) {
65 if (this == object) {
66 return true;
67 }
68 if (object instanceof TeLinkTpKey) {
69 TeLinkTpKey that = (TeLinkTpKey) object;
70 return Objects.equal(teNodeId, that.teNodeId) &&
71 Objects.equal(teLinkTpId, that.teLinkTpId);
72 }
73 return false;
74 }
75
76 @Override
77 public String toString() {
78 return MoreObjects.toStringHelper(getClass())
79 .add("teNodeId", teNodeId)
80 .add("teLinkTpId", teLinkTpId)
81 .toString();
82 }
83}