43203006678ccae5470a2aecdebc0f5614d50e14
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / match / AbstractOxmPortDeserializer.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.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;\r
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry;\r
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder;\r
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
18 \r
19 /**\r
20  * @author michal.polkorab\r
21  *\r
22  */\r
23 public abstract class AbstractOxmPortDeserializer extends AbstractOxmMatchEntryDeserializer\r
24         implements OFDeserializer<MatchEntries> {\r
25 \r
26     @Override\r
27     public MatchEntries deserialize(ByteBuf input) {\r
28         MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);\r
29         addPortAugmentation(builder, input);\r
30         return builder.build();\r
31     }\r
32 \r
33     private static void addPortAugmentation(MatchEntriesBuilder builder, ByteBuf input) {\r
34         PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder();\r
35         portBuilder.setPort(new PortNumber(input.readUnsignedShort()));\r
36         builder.addAugmentation(PortMatchEntry.class, portBuilder.build());\r
37     }\r
38 }\r