Remove Objects.{is,non}Null abuse
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / protocol / serialization / match / VlanPcpEntrySerializer.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.serialization.match;
10
11 import io.netty.buffer.ByteBuf;
12 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
13 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
15
16 public class VlanPcpEntrySerializer extends AbstractMatchEntrySerializer {
17
18     @Override
19     public void serialize(Match match, ByteBuf outBuffer) {
20         super.serialize(match, outBuffer);
21         outBuffer.writeByte(match.getVlanMatch().getVlanPcp().getValue());
22     }
23
24     @Override
25     public boolean matchTypeCheck(Match match) {
26         return match.getVlanMatch() != null && match.getVlanMatch().getVlanPcp() != null;
27     }
28
29     @Override
30     protected boolean getHasMask(Match match) {
31         return false;
32     }
33
34     @Override
35     protected int getOxmFieldCode() {
36         return OxmMatchConstants.VLAN_PCP;
37     }
38
39     @Override
40     protected int getOxmClassCode() {
41         return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
42     }
43
44     @Override
45     protected int getValueLength() {
46         return EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
47     }
48
49 }