blob: 3e479129af1d9b1e2bbfc99187c22b583a70ec7e [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_set_serializer.java
8// Do not modify
9
10package org.projectfloodlight.openflow.protocol.ver13;
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.OFTableConfig;
27import java.util.Set;
28import org.jboss.netty.buffer.ChannelBuffer;
29import com.google.common.hash.PrimitiveSink;
30import java.util.EnumSet;
31import java.util.Collections;
32
33
34public class OFTableConfigSerializerVer13 {
35
36 public final static int DEPRECATED_MASK_VAL = 0x3;
37
38 public static Set<OFTableConfig> readFrom(ChannelBuffer bb) throws OFParseError {
39 try {
40 return ofWireValue(bb.readInt());
41 } catch (IllegalArgumentException e) {
42 throw new OFParseError(e);
43 }
44 }
45
46 public static void writeTo(ChannelBuffer bb, Set<OFTableConfig> set) {
47 bb.writeInt(toWireValue(set));
48 }
49
50 public static void putTo(Set<OFTableConfig> set, PrimitiveSink sink) {
51 sink.putInt(toWireValue(set));
52 }
53
54
55 public static Set<OFTableConfig> ofWireValue(int val) {
56 EnumSet<OFTableConfig> set = EnumSet.noneOf(OFTableConfig.class);
57
58 if((val & DEPRECATED_MASK_VAL) != 0)
59 set.add(OFTableConfig.DEPRECATED_MASK);
60 return Collections.unmodifiableSet(set);
61 }
62
63 public static int toWireValue(Set<OFTableConfig> set) {
64 int wireValue = 0;
65
66 for(OFTableConfig e: set) {
67 switch(e) {
68 case DEPRECATED_MASK:
69 wireValue |= DEPRECATED_MASK_VAL;
70 break;
71 default:
72 throw new IllegalArgumentException("Illegal enum value for type OFTableConfig in version 1.3: " + e);
73 }
74 }
75 return wireValue;
76 }
77
78}