ebd626d379fd4b17833576692d100d2784f48d4e
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / instruction / MeterInstructionDeserializer.java
1 /*\r
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 \r
9 package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction;\r
10 \r
11 import io.netty.buffer.ByteBuf;\r
12 \r
13 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction;\r
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstructionBuilder;\r
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter;\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;\r
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;\r
19 \r
20 /**\r
21  * @author michal.polkorab\r
22  *\r
23  */\r
24 public class MeterInstructionDeserializer extends AbstractInstructionDeserializer {\r
25 \r
26     @Override\r
27     public Instruction deserialize(ByteBuf input) {\r
28         InstructionBuilder builder = new InstructionBuilder();\r
29         input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
30         builder.setType(Meter.class);\r
31         input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);\r
32         MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder();\r
33         meterBuilder.setMeterId(input.readUnsignedInt());\r
34         builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build());\r
35         return builder.build();\r
36     }\r
37 \r
38 }\r