2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
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
9 package org.opendaylight.openflowjava.protocol.impl.serialization.instruction;
11 import io.netty.buffer.ByteBuf;
13 import java.util.List;
15 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
21 * @author michal.polkorab
24 public class WriteActionsInstructionSerializer extends AbstractActionInstructionSerializer {
27 public void serialize(final Instruction instruction, final ByteBuf outBuffer) {
28 int startIndex = outBuffer.writerIndex();
29 outBuffer.writeShort(getType());
30 WriteActionsCase actionsCase = (WriteActionsCase) instruction.getInstructionChoice();
31 if (actionsCase != null) {
32 List<Action> actions = actionsCase.getWriteActions().getAction();
33 writeActions(actions, outBuffer, startIndex);
35 outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH);
36 outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION);
41 protected int getType() {
42 return InstructionConstants.WRITE_ACTIONS_TYPE;