blob: 3e1cb75c61c9b05342e73044896b8336a1b26096 [file] [log] [blame]
Jonathan Hart3c259162015-10-21 21:31:19 -07001/*
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.instructions;
18
19import com.google.common.annotations.Beta;
20import com.google.common.base.MoreObjects;
21
22import java.util.Objects;
23
24/**
25 * Type of extension instructions.
26 */
27@Beta
28public final class ExtensionType {
29
30 /**
31 * A list of well-known named extension instruction type codes.
32 */
33 public enum ExtensionTypes {
34 // TODO fix type numbers to include experimenter id
BitOhenryb53ac6c2015-11-16 20:58:58 +080035 NICIRA_SET_TUNNEL_DST(31),
36 NICIRA_RESUBMIT(32);
Jonathan Hart3c259162015-10-21 21:31:19 -070037
38 private ExtensionType type;
39
40 /**
41 * Creates a new named extension instruction type.
42 *
43 * @param type type code
44 */
45 ExtensionTypes(int type) {
46 this.type = new ExtensionType(type);
47 }
48
49 /**
50 * Gets the extension type object for this named type code.
51 *
52 * @return extension type object
53 */
54 public ExtensionType type() {
55 return type;
56 }
57 }
58
59 private final int type;
60
61 /**
62 * Creates an extension type with the given int type code.
63 *
64 * @param type type code
65 */
66 public ExtensionType(int type) {
67 this.type = type;
68 }
69
70 @Override
71 public int hashCode() {
72 return Objects.hash(type);
73 }
74
75 @Override
76 public boolean equals(Object obj) {
77 if (this == obj) {
78 return true;
79 }
80 if (obj instanceof ExtensionType) {
81 final ExtensionType that = (ExtensionType) obj;
82 return this.type == that.type;
83 }
84 return false;
85 }
86
87 @Override
88 public String toString() {
89 return MoreObjects.toStringHelper(ExtensionType.class)
90 .add("type", type)
91 .toString();
92 }
93}