blob: aa8d15139fd2fb25b66793e8d591ebed767bae5b [file] [log] [blame]
Jonathan Hart26a8d952015-12-02 15:16:35 -08001/*
2 * Copyright 2015 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.flow.criteria;
18
19import com.google.common.annotations.Beta;
20import com.google.common.base.MoreObjects;
21
22import java.util.Objects;
23
24/**
25 * Type of selector extensions.
26 */
27@Beta
28public class ExtensionSelectorType {
29
30 /**
31 * A list of well-known named extension selector type codes.
32 * These numbers have no impact on the actual OF type id.
33 */
34 public enum ExtensionSelectorTypes {
Phaneendra Mandaefb38752015-12-04 00:43:38 +053035 NICIRA_MATCH_NSH_SPI(0),
36 NICIRA_MATCH_NSH_SI(1),
37 NICIRA_MATCH_NSH_CH1(2),
38 NICIRA_MATCH_NSH_CH2(3),
39 NICIRA_MATCH_NSH_CH3(4),
Charles Chan14967c22015-12-07 11:11:50 -080040 NICIRA_MATCH_NSH_CH4(5),
41 OFDPA_MATCH_VLAN_VID(16);
Jonathan Hart26a8d952015-12-02 15:16:35 -080042
43 private ExtensionSelectorType type;
44
45 /**
46 * Creates a new named extension selector type.
47 *
48 * @param type type code
49 */
50 ExtensionSelectorTypes(int type) {
51 this.type = new ExtensionSelectorType(type);
52 }
53
54 /**
55 * Gets the extension type object for this named type code.
56 *
57 * @return extension type object
58 */
59 public ExtensionSelectorType type() {
60 return type;
61 }
62 }
63
64 private final int type;
65
66 /**
67 * Creates an extension type with the given int type code.
68 *
69 * @param type type code
70 */
71 public ExtensionSelectorType(int type) {
72 this.type = type;
73 }
74
75 @Override
76 public int hashCode() {
77 return Objects.hash(type);
78 }
79
80 @Override
81 public boolean equals(Object obj) {
82 if (this == obj) {
83 return true;
84 }
85 if (obj instanceof ExtensionSelectorType) {
86 final ExtensionSelectorType that = (ExtensionSelectorType) obj;
87 return this.type == that.type;
88 }
89 return false;
90 }
91
92 @Override
93 public String toString() {
94 return MoreObjects.toStringHelper(ExtensionSelectorType.class)
95 .add("type", type)
96 .toString();
97 }
98}