Added openflow-codec and openflowj_netty from openflowplugin
[openflowjava.git] / third-party / openflow-codec / src / main / java / org / openflow / codec / protocol / OFPMatchType.java
1 package org.openflow.codec.protocol;
2
3 /**
4  * Represents enum ofp_match_type
5  *
6  * @author AnilGujele
7  *
8  */
9 public enum OFPMatchType {
10     OFPMT_STANDARD((short) 0), OFPMT_OXM((short) 1);
11
12     private short type;
13     private static OFPMatchType[] mapping;
14
15     /**
16      * constructor
17      *
18      * @param value
19      */
20     private OFPMatchType(short value) {
21         type = value;
22         addMapping(type, this);
23
24     }
25
26     /**
27      * add mapping for match type
28      *
29      * @param index
30      *            - match type value is index
31      * @param matchType
32      *            - match type instance is value
33      */
34     private static void addMapping(short index, OFPMatchType matchType) {
35         if (null == mapping) {
36             mapping = new OFPMatchType[2];
37         }
38         mapping[index] = matchType;
39
40     }
41
42     /**
43      * get match type from value
44      *
45      * @param value
46      * @return
47      */
48     public static OFPMatchType valueOf(short value) {
49         return mapping[value];
50     }
51
52     /**
53      * get match type value
54      *
55      * @return
56      */
57     public short getMatchTypeValue() {
58         return type;
59     }
60
61     /**
62      * set match type value
63      *
64      * @param type
65      */
66     public void setMatchTypeValue(short type) {
67         this.type = type;
68     }
69 }