hiroki | ec18d3a | 2018-05-16 15:27:37 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 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 | |
| 17 | package org.onosproject.odtn.utils.tapi; |
| 18 | |
| 19 | import java.util.UUID; |
| 20 | import org.onosproject.net.DeviceId; |
| 21 | |
| 22 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 23 | import static com.google.common.base.Objects.equal; |
| 24 | import static java.util.Objects.hash; |
| 25 | |
| 26 | public class TapiNodeRef { |
| 27 | |
| 28 | private final UUID topologyId; |
| 29 | private final UUID nodeId; |
| 30 | private DeviceId deviceId; |
| 31 | |
| 32 | public String getNodeId() { |
| 33 | return nodeId.toString(); |
| 34 | } |
| 35 | |
| 36 | public DeviceId getDeviceId() { |
| 37 | return deviceId; |
| 38 | } |
| 39 | |
| 40 | public void setDeviceId(DeviceId deviceId) { |
| 41 | this.deviceId = deviceId; |
| 42 | } |
| 43 | |
| 44 | public TapiNodeRef(String topologyId, String nodeId) { |
| 45 | this.topologyId = UUID.fromString(topologyId); |
| 46 | this.nodeId = UUID.fromString(nodeId); |
| 47 | } |
| 48 | |
| 49 | public String toString() { |
| 50 | return toStringHelper(getClass()) |
| 51 | // .add("topologyId", topologyId) |
| 52 | .add("nodeId", nodeId) |
| 53 | .add("deviceId", deviceId) |
| 54 | .toString(); |
| 55 | } |
| 56 | |
| 57 | @Override |
| 58 | public boolean equals(Object o) { |
| 59 | if (this == o) { |
| 60 | return true; |
| 61 | } |
| 62 | if (!(o instanceof TapiNodeRef)) { |
| 63 | return false; |
| 64 | } |
| 65 | TapiNodeRef nodeRef = (TapiNodeRef) o; |
| 66 | return equal(topologyId, nodeRef.topologyId) && |
| 67 | equal(nodeId, nodeRef.nodeId); |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public int hashCode() { |
| 72 | return hash(topologyId, nodeId); |
| 73 | } |
| 74 | |
| 75 | } |