Mass replace CRLF->LF
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / match / OxmMplsBosDeserializer.java
1 /*
2  * Copyright (c) 2013 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 package org.opendaylight.openflowjava.protocol.impl.deserialization.match;
9
10 import io.netty.buffer.ByteBuf;
11
12 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
21
22 /**
23  * @author michal.polkorab
24  *
25  */
26 public class OxmMplsBosDeserializer extends AbstractOxmMatchEntryDeserializer
27         implements OFDeserializer<MatchEntries> {
28
29     @Override
30     public MatchEntries deserialize(ByteBuf input) {
31         MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);
32         addMplsBosDeserializer(input, builder);
33         return builder.build();
34     }
35
36
37     private static void addMplsBosDeserializer(ByteBuf input,
38             MatchEntriesBuilder builder) {
39         BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder();
40         if (input.readUnsignedByte() != 0) {
41             bosBuilder.setBos(true);
42         } else {
43             bosBuilder.setBos(false);
44         }
45         builder.addAugmentation(BosMatchEntry.class, bosBuilder.build());
46     }
47
48     @Override
49     protected Class<? extends MatchField> getOxmField() {
50         return MplsBos.class;
51     }
52
53     @Override
54     protected Class<? extends OxmClassBase> getOxmClass() {
55         return OpenflowBasicClass.class;
56     }
57 }