0600d2961719367e49498f399a451102750e98e8
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / match / OxmVlanPcpDeserializer.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 package org.opendaylight.openflowjava.protocol.impl.deserialization.match;\r
9 \r
10 import io.netty.buffer.ByteBuf;\r
11 \r
12 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;\r
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry;\r
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntryBuilder;\r
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase;\r
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp;\r
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
21 \r
22 /**\r
23  * @author michal.polkorab\r
24  *\r
25  */\r
26 public class OxmVlanPcpDeserializer extends AbstractOxmMatchEntryDeserializer\r
27         implements OFDeserializer<MatchEntries> {\r
28 \r
29     @Override\r
30     public MatchEntries deserialize(ByteBuf input) {\r
31         MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
32         addVlanPcpAugmentation(input, builder);\r
33         return builder.build();\r
34     }\r
35 \r
36     private static void addVlanPcpAugmentation(ByteBuf input, MatchEntriesBuilder builder) {\r
37         VlanPcpMatchEntryBuilder vlanPcpBuilder = new VlanPcpMatchEntryBuilder();\r
38         vlanPcpBuilder.setVlanPcp(input.readUnsignedByte());\r
39         builder.addAugmentation(VlanPcpMatchEntry.class, vlanPcpBuilder.build());\r
40     }\r
41 \r
42     @Override\r
43     protected Class<? extends MatchField> getOxmField() {\r
44         return VlanPcp.class;\r
45     }\r
46 \r
47     @Override\r
48     protected Class<? extends OxmClassBase> getOxmClass() {\r
49         return OpenflowBasicClass.class;\r
50     }\r
51 }\r