blob: ab9eee5e3981925e336014205727336598e60ff4 [file] [log] [blame]
samuel8d6b0a92015-07-11 13:22:57 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
samuel8d6b0a92015-07-11 13:22:57 +08003 *
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
17package org.onosproject.net.behaviour;
18
Hyunsun Moondd14e8e2016-06-09 16:17:32 -070019import java.util.Objects;
samuel8d6b0a92015-07-11 13:22:57 +080020
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 */
Ray Milkey201f04b2017-09-25 10:13:19 -070025public final class TunnelEndPoint<T> {
samuel8d6b0a92015-07-11 13:22:57 +080026
Ray Milkey201f04b2017-09-25 10:13:19 -070027 private final T value;
Hyunsun Moondd14e8e2016-06-09 16:17:32 -070028
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 }
samuel8d6b0a92015-07-11 13:22:57 +080073}