aa4c5175d3313b32d9f7020e7900d23f4e95fee2
[openflowjava.git] / third-party / openflow-codec / src / main / java / org / openflow / codec / protocol / OFPFlowModCommand.java
1 package org.openflow.codec.protocol;
2
3 /**
4  * Correspond to enum ofp_flow_mod_command
5  *
6  * @author AnilGujele
7  *
8  */
9 public enum OFPFlowModCommand {
10     /* New flow. */
11     OFPFC_ADD((byte) 0),
12     /* Modify all matching flows. */
13     OFPFC_MODIFY((byte) 1),
14     /* Modify entry strictly matching wildcards and priority. */
15     OFPFC_MODIFY_STRICT((byte) 2),
16     /* Delete all matching flows. */
17     OFPFC_DELETE((byte) 3),
18     /* Delete entry strictly matching wildcards and priority. */
19     OFPFC_DELETE_STRICT((byte) 4);
20
21     private byte value;
22
23     private static OFPFlowModCommand[] mapping;
24
25     OFPFlowModCommand(byte value) {
26         this.value = value;
27         addMapping(value, this);
28     }
29
30     /**
31      * add mapping
32      *
33      * @param key
34      * @param value
35      */
36     private static void addMapping(byte index, OFPFlowModCommand value) {
37         if (null == mapping) {
38             mapping = new OFPFlowModCommand[5];
39         }
40         mapping[index] = value;
41
42     }
43
44     /**
45      * get the enum having this value
46      *
47      * @param value
48      * @return
49      */
50     public static OFPFlowModCommand valueOf(byte value) {
51         return mapping[value];
52     }
53
54     /**
55      *
56      * @return
57      */
58     public byte getValue() {
59         return value;
60     }
61
62     /**
63      *
64      * @param value
65      */
66     public void setValue(byte value) {
67         this.value = value;
68     }
69
70 }