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.link; |
| 17 | |
| 18 | import com.google.common.base.MoreObjects; |
| 19 | import com.google.common.base.Objects; |
| 20 | |
| 21 | /** |
| 22 | * Representation of a TE tunnel identifier. |
| 23 | */ |
| 24 | public class TeTunnelId { |
| 25 | private final long srcTeNodeId; |
| 26 | private final long dstTeNodeId; |
| 27 | private final long tunnelId; |
| 28 | |
| 29 | /** |
| 30 | * Create a TE tunnel identifier. |
| 31 | * |
| 32 | * @param srcTeNodeId source TE node id |
| 33 | * @param dstTeNodeId destination TE node id |
| 34 | * @param tunnelId tunnel id |
| 35 | */ |
| 36 | public TeTunnelId(long srcTeNodeId, long dstTeNodeId, long tunnelId) { |
| 37 | this.srcTeNodeId = srcTeNodeId; |
| 38 | this.dstTeNodeId = dstTeNodeId; |
| 39 | this.tunnelId = tunnelId; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Returns the source TE node identifier of the tunnel. |
| 44 | * |
| 45 | * @return the source TE node id |
| 46 | */ |
| 47 | public long sourceTeNodeId() { |
| 48 | return srcTeNodeId; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Returns the destination TE node identifier of the tunnel. |
| 53 | * |
| 54 | * @return the destination TE node id |
| 55 | */ |
| 56 | public long destinationTeNodeId() { |
| 57 | return dstTeNodeId; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Returns the tunnel identifier. |
| 62 | * |
| 63 | * @return the tunnel id |
| 64 | */ |
| 65 | public long tunnelId() { |
| 66 | return tunnelId; |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public int hashCode() { |
| 71 | return Objects.hashCode(srcTeNodeId, dstTeNodeId, tunnelId); |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public boolean equals(Object object) { |
| 76 | if (this == object) { |
| 77 | return true; |
| 78 | } |
| 79 | if (object instanceof TeTunnelId) { |
| 80 | TeTunnelId that = (TeTunnelId) object; |
| 81 | return (srcTeNodeId == that.srcTeNodeId) && |
| 82 | (dstTeNodeId == that.dstTeNodeId) && |
| 83 | (tunnelId == that.tunnelId); |
| 84 | } |
| 85 | return false; |
| 86 | } |
| 87 | |
| 88 | @Override |
| 89 | public String toString() { |
| 90 | return MoreObjects.toStringHelper(getClass()) |
| 91 | .add("srcTeNodeId", srcTeNodeId) |
| 92 | .add("dstTeNodeId", dstTeNodeId) |
| 93 | .add("tunnelId", tunnelId) |
| 94 | .toString(); |
| 95 | } |
| 96 | |
| 97 | } |