samuel | 8d6b0a9 | 2015-07-11 13:22:57 +0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
samuel | 8d6b0a9 | 2015-07-11 13:22:57 +0800 | [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 | |
| 17 | package org.onosproject.net.behaviour; |
| 18 | |
Hyunsun Moon | dd14e8e | 2016-06-09 16:17:32 -0700 | [diff] [blame] | 19 | import java.util.Objects; |
samuel | 8d6b0a9 | 2015-07-11 13:22:57 +0800 | [diff] [blame] | 20 | |
| 21 | /** |
| 22 | * Represents for source end point or destination end point of a tunnel. Maybe a tunnel |
| 23 | * based on ConnectPoint, IpAddress, MacAddress and so on is built. |
| 24 | */ |
Hyunsun Moon | dd14e8e | 2016-06-09 16:17:32 -0700 | [diff] [blame] | 25 | public class TunnelEndPoint<T> { |
samuel | 8d6b0a9 | 2015-07-11 13:22:57 +0800 | [diff] [blame] | 26 | |
Hyunsun Moon | dd14e8e | 2016-06-09 16:17:32 -0700 | [diff] [blame] | 27 | protected final T value; |
| 28 | |
| 29 | /** |
| 30 | * Default constructor. |
| 31 | * |
| 32 | * @param value value of the tunnel endpoint |
| 33 | */ |
| 34 | public TunnelEndPoint(T value) { |
| 35 | this.value = value; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Returns the value. |
| 40 | * |
| 41 | * @return tunnel endpoint value |
| 42 | */ |
| 43 | public T value() { |
| 44 | return value; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Returns the value as a string. |
| 49 | * |
| 50 | * @return string value |
| 51 | */ |
| 52 | public String strValue() { |
| 53 | return value.toString(); |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public boolean equals(Object obj) { |
| 58 | if (this == obj) { |
| 59 | return true; |
| 60 | } |
| 61 | if (obj instanceof TunnelEndPoint) { |
| 62 | final TunnelEndPoint that = (TunnelEndPoint) obj; |
| 63 | return this.getClass() == that.getClass() && |
| 64 | Objects.equals(this.value, that.value); |
| 65 | } |
| 66 | return false; |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public int hashCode() { |
| 71 | return value.hashCode(); |
| 72 | } |
samuel | 8d6b0a9 | 2015-07-11 13:22:57 +0800 | [diff] [blame] | 73 | } |