alshabib | 86ac11c | 2014-08-14 16:14:41 -0700 | [diff] [blame^] | 1 | // 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 | |
| 10 | package org.projectfloodlight.openflow.protocol.ver11; |
| 11 | |
| 12 | import org.projectfloodlight.openflow.protocol.*; |
| 13 | import org.projectfloodlight.openflow.protocol.action.*; |
| 14 | import org.projectfloodlight.openflow.protocol.actionid.*; |
| 15 | import org.projectfloodlight.openflow.protocol.bsntlv.*; |
| 16 | import org.projectfloodlight.openflow.protocol.errormsg.*; |
| 17 | import org.projectfloodlight.openflow.protocol.meterband.*; |
| 18 | import org.projectfloodlight.openflow.protocol.instruction.*; |
| 19 | import org.projectfloodlight.openflow.protocol.instructionid.*; |
| 20 | import org.projectfloodlight.openflow.protocol.match.*; |
| 21 | import org.projectfloodlight.openflow.protocol.oxm.*; |
| 22 | import org.projectfloodlight.openflow.protocol.queueprop.*; |
| 23 | import org.projectfloodlight.openflow.types.*; |
| 24 | import org.projectfloodlight.openflow.util.*; |
| 25 | import org.projectfloodlight.openflow.exceptions.*; |
| 26 | import org.projectfloodlight.openflow.protocol.OFPortReason; |
| 27 | import org.jboss.netty.buffer.ChannelBuffer; |
| 28 | import com.google.common.hash.PrimitiveSink; |
| 29 | |
| 30 | public class OFPortReasonSerializerVer11 { |
| 31 | |
| 32 | public final static byte ADD_VAL = (byte) 0x0; |
| 33 | public final static byte DELETE_VAL = (byte) 0x1; |
| 34 | public final static byte MODIFY_VAL = (byte) 0x2; |
| 35 | |
| 36 | public static OFPortReason readFrom(ChannelBuffer bb) throws OFParseError { |
| 37 | try { |
| 38 | return ofWireValue(bb.readByte()); |
| 39 | } catch (IllegalArgumentException e) { |
| 40 | throw new OFParseError(e); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | public static void writeTo(ChannelBuffer bb, OFPortReason e) { |
| 45 | bb.writeByte(toWireValue(e)); |
| 46 | } |
| 47 | |
| 48 | public static void putTo(OFPortReason e, PrimitiveSink sink) { |
| 49 | sink.putByte(toWireValue(e)); |
| 50 | } |
| 51 | |
| 52 | public static OFPortReason ofWireValue(byte val) { |
| 53 | switch(val) { |
| 54 | case ADD_VAL: |
| 55 | return OFPortReason.ADD; |
| 56 | case DELETE_VAL: |
| 57 | return OFPortReason.DELETE; |
| 58 | case MODIFY_VAL: |
| 59 | return OFPortReason.MODIFY; |
| 60 | default: |
| 61 | throw new IllegalArgumentException("Illegal wire value for type OFPortReason in version 1.1: " + val); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | |
| 66 | public static byte toWireValue(OFPortReason e) { |
| 67 | switch(e) { |
| 68 | case ADD: |
| 69 | return ADD_VAL; |
| 70 | case DELETE: |
| 71 | return DELETE_VAL; |
| 72 | case MODIFY: |
| 73 | return MODIFY_VAL; |
| 74 | default: |
| 75 | throw new IllegalArgumentException("Illegal enum value for type OFPortReason in version 1.1: " + e); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | } |