InstructionDeserializer split into separate deserializers
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / instruction / GoToTableInstructionDeserializer.java
diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java
new file mode 100644 (file)
index 0000000..d3ed865
--- /dev/null
@@ -0,0 +1,39 @@
+/*\r
+ * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;\r
+import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class GoToTableInstructionDeserializer extends AbstractInstructionDeserializer {\r
+\r
+    @Override\r
+    public Instruction deserialize(ByteBuf input) {\r
+        InstructionBuilder builder = new InstructionBuilder();\r
+        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+        builder.setType(GotoTable.class);\r
+        input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
+        TableIdInstructionBuilder tableBuilder = new TableIdInstructionBuilder();\r
+        tableBuilder.setTableId(input.readUnsignedByte());\r
+        builder.addAugmentation(TableIdInstruction.class, tableBuilder.build());\r
+        input.skipBytes(InstructionConstants.PADDING_IN_GOTO_TABLE);\r
+        return builder.build();\r
+    }\r
+}\r