blob: 527b44a9801a20667ba562e5c82fe75fcf4a4fad [file] [log] [blame]
Hyunsun Moondd14e8e2016-06-09 16:17:32 -07001/*
2 * Copyright 2016-present Open Networking Laboratory
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
17package org.onosproject.net.behaviour;
18
19import java.util.Objects;
20
21/**
22 * Represent for a tunnel key. The tunnel accepts packets with the tunnel key.
23 * A positive 24-bit (for Geneve, VXLAN, and LISP), 32-bit (for GRE) or 64-bit (for
24 * GRE64) number value is used for example. Open vSwitch allows "flow" as the key
25 * to set this value with matching in the flow table.
26 */
27public final class TunnelKey<T> {
28
29 private final T value;
30
31 /**
32 * Default constructor.
33 *
34 * @param value value of the tunnel key
35 */
36 public TunnelKey(T value) {
37 this.value = value;
38 }
39
40 /**
41 * Returns the value.
42 *
43 * @return tunnel key value
44 */
45 public T value() {
46 return value;
47 }
48
49 /**
50 * Returns the value as a string.
51 *
52 * @return string value
53 */
54 public String strValue() {
55 return value.toString();
56 }
57
58 @Override
59 public boolean equals(Object obj) {
60 if (this == obj) {
61 return true;
62 }
63 if (obj instanceof TunnelKey) {
64 final TunnelKey that = (TunnelKey) obj;
65 return this.getClass() == that.getClass() &&
66 Objects.equals(this.value, that.value);
67 }
68 return false;
69 }
70
71 @Override
72 public int hashCode() {
73 return value.hashCode();
74 }
75}