Remove Objects.{is,non}Null abuse
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / protocol / serialization / match / PacketTypeEntrySerializer.java
1 /*
2  * Copyright (c) 2018 SUSE LINUX GmbH.  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.EncodeConstants;
12 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
14
15 public class PacketTypeEntrySerializer extends AbstractMatchEntrySerializer {
16     @Override
17     public void serialize(Match match, ByteBuf outBuffer) {
18         super.serialize(match, outBuffer);
19         outBuffer.writeInt(match.getPacketTypeMatch().getPacketType().intValue());
20     }
21
22     @Override
23     protected boolean getHasMask(Match match) {
24         return false;
25     }
26
27     @Override
28     protected int getOxmFieldCode() {
29         return OxmMatchConstants.PACKET_TYPE;
30     }
31
32     @Override
33     protected int getOxmClassCode() {
34         return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
35     }
36
37     @Override
38     protected int getValueLength() {
39         return EncodeConstants.SIZE_OF_INT_IN_BYTES;
40     }
41
42     @Override
43     public boolean matchTypeCheck(Match match) {
44         return match.getPacketTypeMatch() != null && match.getPacketTypeMatch().getPacketType() != null;
45     }
46 }