Remove bundle extension (de)serializers
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / instruction / ApplyActionsInstructionDeserializer.java
1 /*
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;
10
11 import io.netty.buffer.ByteBuf;
12
13 import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
14 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
15 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
20
21 /**
22  * @author michal.polkorab
23  *
24  */
25 public class ApplyActionsInstructionDeserializer extends AbstractActionInstructionDeserializer
26         implements HeaderDeserializer<Instruction> {
27
28     @Override
29     public Instruction deserialize(ByteBuf input) {
30         InstructionBuilder builder = new InstructionBuilder();
31         input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
32         int instructionLength = input.readUnsignedShort();
33         input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
34         ApplyActionsCaseBuilder caseBuilder = new ApplyActionsCaseBuilder();
35         ApplyActionsBuilder actionsBuilder = new ApplyActionsBuilder();
36         actionsBuilder.setAction(deserializeActions(input, instructionLength));
37         caseBuilder.setApplyActions(actionsBuilder.build());
38         builder.setInstructionChoice(caseBuilder.build());
39         return builder.build();
40     }
41
42     @Override
43     public Instruction deserializeHeader(ByteBuf input) {
44         InstructionBuilder builder = new InstructionBuilder();
45         input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
46         builder.setInstructionChoice(new ApplyActionsCaseBuilder().build());
47         return builder.build();
48     }
49
50 }