blob: f4a57f408e1fb16e643eb2ead1f7d7db0b559e95 [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.node;
17
18import static com.google.common.base.MoreObjects.toStringHelper;
19
20import org.onosproject.tetopology.management.api.KeyId;
21
22import com.google.common.base.Objects;
23
24/**
25 * Representation of a termination point key or reference.
26 */
27public class TerminationPointKey extends NetworkNodeKey {
28 private final KeyId tpId;
29
30 /**
31 * Creates an instance of TerminationPointKey.
32 *
33 * @param networkId network identifier
34 * @param nodeId node identifier
35 * @param tpId termination point identifier
36 */
37 public TerminationPointKey(KeyId networkId, KeyId nodeId, KeyId tpId) {
38 super(networkId, nodeId);
39 this.tpId = tpId;
40 }
41
42 /**
43 * Returns the termination point Id.
44 *
45 * @return termination point identifier
46 */
47 public KeyId tpId() {
48 return tpId;
49 }
50
51 @Override
52 public int hashCode() {
53 return Objects.hashCode(super.hashCode(), tpId);
54 }
55
56 @Override
57 public boolean equals(Object object) {
58 if (object instanceof TerminationPointKey) {
59 if (!super.equals(object)) {
60 return false;
61 }
62 TerminationPointKey that = (TerminationPointKey) object;
63 return Objects.equal(this.tpId, that.tpId);
64 }
65 return false;
66 }
67
68 @Override
69 public String toString() {
70 return toStringHelper(this)
71 .add("networkId", networkId())
72 .add("nodeId", nodeId())
73 .add("tpId", tpId)
74 .toString();
75 }
76
77}