Remove EncodeConstants.SIZE_OF_{BYTE,SHORT,INT,LONG}_IN_BYTES
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / protocol / serialization / match / MplsBosEntrySerializer.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 package org.opendaylight.openflowplugin.impl.protocol.serialization.match;
9
10 import io.netty.buffer.ByteBuf;
11 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFields;
14 import org.opendaylight.yangtools.yang.common.Uint8;
15
16 public class MplsBosEntrySerializer extends AbstractPrimitiveEntrySerializer<Uint8> {
17     public MplsBosEntrySerializer() {
18         super(OxmMatchConstants.OPENFLOW_BASIC_CLASS, OxmMatchConstants.MPLS_BOS, Byte.BYTES);
19     }
20
21     @Override
22     protected Uint8 extractEntry(final Match match) {
23         final ProtocolMatchFields protoFields = match.getProtocolMatchFields();
24         return protoFields == null ? null : protoFields.getMplsBos();
25     }
26
27     @Override
28     protected void serializeEntry(final Uint8 entry, final ByteBuf outBuffer) {
29         outBuffer.writeBoolean(entry.byteValue() != 0);
30     }
31 }