Merge "Replace odl-dlux-core with odl-dluxapps-topology"
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / protocol / deserialization / match / MplsBosEntryDeserializer.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.deserialization.match;
10
11 import java.util.Objects;
12
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
15
16 import io.netty.buffer.ByteBuf;
17
18 public class MplsBosEntryDeserializer extends AbstractMatchEntryDeserializer {
19
20     @Override
21     public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
22         processHeader(message);
23         final short mplsBos = message.readUnsignedByte();
24
25         if (Objects.isNull(builder.getProtocolMatchFields())) {
26             builder.setProtocolMatchFields(new ProtocolMatchFieldsBuilder()
27                     .setMplsBos(mplsBos)
28                     .build());
29         } else if (Objects.isNull(builder.getProtocolMatchFields().getMplsBos())) {
30             builder.setProtocolMatchFields(new ProtocolMatchFieldsBuilder(builder.getProtocolMatchFields())
31                     .setMplsBos(mplsBos)
32                     .build());
33         } else {
34             throwErrorOnMalformed(builder, "protocolMatchFields", "mplsBos");
35         }
36     }
37
38 }