Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame^] | 2 | * Copyright 2016 Open Networking Foundation |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.tetopology.management.api.node; |
| 17 | |
| 18 | import org.onosproject.tetopology.management.api.KeyId; |
| 19 | |
| 20 | import com.google.common.base.MoreObjects; |
| 21 | import com.google.common.base.Objects; |
| 22 | |
| 23 | /** |
| 24 | * Representation of a node's termination point key under a known network. |
| 25 | */ |
| 26 | public class NodeTpKey { |
| 27 | private final KeyId nodeId; |
| 28 | private final KeyId tpId; |
| 29 | |
| 30 | /** |
| 31 | * Creates a node's termination point key. |
| 32 | * |
| 33 | * @param nodeId node identifier |
| 34 | * @param tpId termination point identifier |
| 35 | */ |
| 36 | public NodeTpKey(KeyId nodeId, KeyId tpId) { |
| 37 | this.nodeId = nodeId; |
| 38 | this.tpId = tpId; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Returns the node identifier. |
| 43 | * |
| 44 | * @return node id |
| 45 | */ |
| 46 | public KeyId nodeId() { |
| 47 | return nodeId; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Returns the termination point identifier. |
| 52 | * |
| 53 | * @return termination point identifier |
| 54 | */ |
| 55 | public KeyId tpId() { |
| 56 | return tpId; |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public int hashCode() { |
| 61 | return Objects.hashCode(nodeId, tpId); |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public boolean equals(Object object) { |
| 66 | if (this == object) { |
| 67 | return true; |
| 68 | } |
| 69 | if (object instanceof NodeTpKey) { |
| 70 | NodeTpKey that = (NodeTpKey) object; |
| 71 | return Objects.equal(nodeId, that.nodeId) && |
| 72 | Objects.equal(tpId, that.tpId); |
| 73 | } |
| 74 | return false; |
| 75 | } |
| 76 | |
| 77 | @Override |
| 78 | public String toString() { |
| 79 | return MoreObjects.toStringHelper(this) |
| 80 | .add("nodeId", nodeId) |
| 81 | .add("tpId", tpId) |
| 82 | .toString(); |
| 83 | } |
| 84 | |
| 85 | } |