blob: a00082f102152035d8661cebdb5b263ce20d651d [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.OFStatsRequestFlags;
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 OFStatsRequestFlagsSerializerVer13 {
35
36 public final static short REQ_MORE_VAL = (short) 0x1;
37
38 public static Set<OFStatsRequestFlags> readFrom(ChannelBuffer bb) throws OFParseError {
39 try {
40 return ofWireValue(bb.readShort());
41 } catch (IllegalArgumentException e) {
42 throw new OFParseError(e);
43 }
44 }
45
46 public static void writeTo(ChannelBuffer bb, Set<OFStatsRequestFlags> set) {
47 bb.writeShort(toWireValue(set));
48 }
49
50 public static void putTo(Set<OFStatsRequestFlags> set, PrimitiveSink sink) {
51 sink.putShort(toWireValue(set));
52 }
53
54
55 public static Set<OFStatsRequestFlags> ofWireValue(short val) {
56 EnumSet<OFStatsRequestFlags> set = EnumSet.noneOf(OFStatsRequestFlags.class);
57
58 if((val & REQ_MORE_VAL) != 0)
59 set.add(OFStatsRequestFlags.REQ_MORE);
60 return Collections.unmodifiableSet(set);
61 }
62
63 public static short toWireValue(Set<OFStatsRequestFlags> set) {
64 short wireValue = 0;
65
66 for(OFStatsRequestFlags e: set) {
67 switch(e) {
68 case REQ_MORE:
69 wireValue |= REQ_MORE_VAL;
70 break;
71 default:
72 throw new IllegalArgumentException("Illegal enum value for type OFStatsRequestFlags in version 1.3: " + e);
73 }
74 }
75 return wireValue;
76 }
77
78}