blob: 1865226101845a66560b631d18453c642f603a75 [file] [log] [blame]
tom0eb04ca2014-08-25 14:34:51 -07001// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2// Copyright (c) 2011, 2012 Open Networking Foundation
3// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4// This library was generated by the LoxiGen Compiler.
5// See the file LICENSE.txt which should have been included in the source distribution
6
7// Automatically generated by LOXI from template const_serializer.java
8// Do not modify
9
10package org.projectfloodlight.openflow.protocol.ver12;
11
12import org.projectfloodlight.openflow.protocol.*;
13import org.projectfloodlight.openflow.protocol.action.*;
14import org.projectfloodlight.openflow.protocol.actionid.*;
15import org.projectfloodlight.openflow.protocol.bsntlv.*;
16import org.projectfloodlight.openflow.protocol.errormsg.*;
17import org.projectfloodlight.openflow.protocol.meterband.*;
18import org.projectfloodlight.openflow.protocol.instruction.*;
19import org.projectfloodlight.openflow.protocol.instructionid.*;
20import org.projectfloodlight.openflow.protocol.match.*;
21import org.projectfloodlight.openflow.protocol.oxm.*;
22import org.projectfloodlight.openflow.protocol.queueprop.*;
23import org.projectfloodlight.openflow.types.*;
24import org.projectfloodlight.openflow.util.*;
25import org.projectfloodlight.openflow.exceptions.*;
26import org.projectfloodlight.openflow.protocol.OFFlowModCommand;
27import org.jboss.netty.buffer.ChannelBuffer;
28import com.google.common.hash.PrimitiveSink;
29
30public class OFFlowModCommandSerializerVer12 {
31
32 public final static byte ADD_VAL = (byte) 0x0;
33 public final static byte MODIFY_VAL = (byte) 0x1;
34 public final static byte MODIFY_STRICT_VAL = (byte) 0x2;
35 public final static byte DELETE_VAL = (byte) 0x3;
36 public final static byte DELETE_STRICT_VAL = (byte) 0x4;
37
38 public static OFFlowModCommand readFrom(ChannelBuffer bb) throws OFParseError {
39 try {
40 return ofWireValue(bb.readByte());
41 } catch (IllegalArgumentException e) {
42 throw new OFParseError(e);
43 }
44 }
45
46 public static void writeTo(ChannelBuffer bb, OFFlowModCommand e) {
47 bb.writeByte(toWireValue(e));
48 }
49
50 public static void putTo(OFFlowModCommand e, PrimitiveSink sink) {
51 sink.putByte(toWireValue(e));
52 }
53
54 public static OFFlowModCommand ofWireValue(byte val) {
55 switch(val) {
56 case ADD_VAL:
57 return OFFlowModCommand.ADD;
58 case MODIFY_VAL:
59 return OFFlowModCommand.MODIFY;
60 case MODIFY_STRICT_VAL:
61 return OFFlowModCommand.MODIFY_STRICT;
62 case DELETE_VAL:
63 return OFFlowModCommand.DELETE;
64 case DELETE_STRICT_VAL:
65 return OFFlowModCommand.DELETE_STRICT;
66 default:
67 throw new IllegalArgumentException("Illegal wire value for type OFFlowModCommand in version 1.2: " + val);
68 }
69 }
70
71
72 public static byte toWireValue(OFFlowModCommand e) {
73 switch(e) {
74 case ADD:
75 return ADD_VAL;
76 case MODIFY:
77 return MODIFY_VAL;
78 case MODIFY_STRICT:
79 return MODIFY_STRICT_VAL;
80 case DELETE:
81 return DELETE_VAL;
82 case DELETE_STRICT:
83 return DELETE_STRICT_VAL;
84 default:
85 throw new IllegalArgumentException("Illegal enum value for type OFFlowModCommand in version 1.2: " + e);
86 }
87 }
88
89}