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.OFFlowRemovedReason; |
| 27 | import org.jboss.netty.buffer.ChannelBuffer; |
| 28 | import com.google.common.hash.PrimitiveSink; |
| 29 | |
| 30 | public class OFFlowRemovedReasonSerializerVer11 { |
| 31 | |
| 32 | public final static byte IDLE_TIMEOUT_VAL = (byte) 0x0; |
| 33 | public final static byte HARD_TIMEOUT_VAL = (byte) 0x1; |
| 34 | public final static byte DELETE_VAL = (byte) 0x2; |
| 35 | public final static byte GROUP_DELETE_VAL = (byte) 0x3; |
| 36 | |
| 37 | public static OFFlowRemovedReason readFrom(ChannelBuffer bb) throws OFParseError { |
| 38 | try { |
| 39 | return ofWireValue(bb.readByte()); |
| 40 | } catch (IllegalArgumentException e) { |
| 41 | throw new OFParseError(e); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | public static void writeTo(ChannelBuffer bb, OFFlowRemovedReason e) { |
| 46 | bb.writeByte(toWireValue(e)); |
| 47 | } |
| 48 | |
| 49 | public static void putTo(OFFlowRemovedReason e, PrimitiveSink sink) { |
| 50 | sink.putByte(toWireValue(e)); |
| 51 | } |
| 52 | |
| 53 | public static OFFlowRemovedReason ofWireValue(byte val) { |
| 54 | switch(val) { |
| 55 | case IDLE_TIMEOUT_VAL: |
| 56 | return OFFlowRemovedReason.IDLE_TIMEOUT; |
| 57 | case HARD_TIMEOUT_VAL: |
| 58 | return OFFlowRemovedReason.HARD_TIMEOUT; |
| 59 | case DELETE_VAL: |
| 60 | return OFFlowRemovedReason.DELETE; |
| 61 | case GROUP_DELETE_VAL: |
| 62 | return OFFlowRemovedReason.GROUP_DELETE; |
| 63 | default: |
| 64 | throw new IllegalArgumentException("Illegal wire value for type OFFlowRemovedReason in version 1.1: " + val); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | |
| 69 | public static byte toWireValue(OFFlowRemovedReason e) { |
| 70 | switch(e) { |
| 71 | case IDLE_TIMEOUT: |
| 72 | return IDLE_TIMEOUT_VAL; |
| 73 | case HARD_TIMEOUT: |
| 74 | return HARD_TIMEOUT_VAL; |
| 75 | case DELETE: |
| 76 | return DELETE_VAL; |
| 77 | case GROUP_DELETE: |
| 78 | return GROUP_DELETE_VAL; |
| 79 | default: |
| 80 | throw new IllegalArgumentException("Illegal enum value for type OFFlowRemovedReason in version 1.1: " + e); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | } |