Merge "OPNFLWPLUG-963 : Updating ports delete reason from OFP:"
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / protocol / serialization / instructions / MeterInstructionSerializer.java
1 /*
2  * Copyright (c) 2016 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.openflowplugin.impl.protocol.serialization.instructions;
10
11 import io.netty.buffer.ByteBuf;
12 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCase;
15
16 public class MeterInstructionSerializer extends AbstractInstructionSerializer {
17
18     @Override
19     public void serialize(Instruction input, ByteBuf outBuffer) {
20         super.serialize(input, outBuffer);
21         outBuffer.writeInt(MeterCase.class.cast(input).getMeter().getMeterId().getValue().intValue());
22     }
23
24     @Override
25     protected int getType() {
26         return InstructionConstants.METER_TYPE;
27     }
28
29     @Override
30     protected int getLength() {
31         return InstructionConstants.STANDARD_INSTRUCTION_LENGTH;
32     }
33
34 }