blob: f318a483ed3d4f8e1411d3f387a08b3e10605b27 [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.ver10;
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.OFNiciraControllerRole;
27import org.jboss.netty.buffer.ChannelBuffer;
28import com.google.common.hash.PrimitiveSink;
29
30public class OFNiciraControllerRoleSerializerVer10 {
31
32 public final static int ROLE_OTHER_VAL = 0x0;
33 public final static int ROLE_MASTER_VAL = 0x1;
34 public final static int ROLE_SLAVE_VAL = 0x2;
35
36 public static OFNiciraControllerRole readFrom(ChannelBuffer bb) throws OFParseError {
37 try {
38 return ofWireValue(bb.readInt());
39 } catch (IllegalArgumentException e) {
40 throw new OFParseError(e);
41 }
42 }
43
44 public static void writeTo(ChannelBuffer bb, OFNiciraControllerRole e) {
45 bb.writeInt(toWireValue(e));
46 }
47
48 public static void putTo(OFNiciraControllerRole e, PrimitiveSink sink) {
49 sink.putInt(toWireValue(e));
50 }
51
52 public static OFNiciraControllerRole ofWireValue(int val) {
53 switch(val) {
54 case ROLE_OTHER_VAL:
55 return OFNiciraControllerRole.ROLE_OTHER;
56 case ROLE_MASTER_VAL:
57 return OFNiciraControllerRole.ROLE_MASTER;
58 case ROLE_SLAVE_VAL:
59 return OFNiciraControllerRole.ROLE_SLAVE;
60 default:
61 throw new IllegalArgumentException("Illegal wire value for type OFNiciraControllerRole in version 1.0: " + val);
62 }
63 }
64
65
66 public static int toWireValue(OFNiciraControllerRole e) {
67 switch(e) {
68 case ROLE_OTHER:
69 return ROLE_OTHER_VAL;
70 case ROLE_MASTER:
71 return ROLE_MASTER_VAL;
72 case ROLE_SLAVE:
73 return ROLE_SLAVE_VAL;
74 default:
75 throw new IllegalArgumentException("Illegal enum value for type OFNiciraControllerRole in version 1.0: " + e);
76 }
77 }
78
79}