Bump mdsal to 5.0.2
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / protocol / serialization / match / UdpDestinationPortEntrySerializer.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.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 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
15
16 public class UdpDestinationPortEntrySerializer extends AbstractMatchEntrySerializer {
17
18     @Override
19     public void serialize(final Match match, final ByteBuf outBuffer) {
20         super.serialize(match, outBuffer);
21         outBuffer.writeShort(((UdpMatch) match.getLayer4Match()).getUdpDestinationPort().getValue().toJava());
22     }
23
24     @Override
25     public boolean matchTypeCheck(final Match match) {
26         return match.getLayer4Match() != null
27                 && match.getLayer4Match() instanceof UdpMatch
28                 && ((UdpMatch) match.getLayer4Match()).getUdpDestinationPort() != null;
29     }
30
31     @Override
32     protected boolean getHasMask(final Match match) {
33         return false;
34     }
35
36     @Override
37     protected int getOxmFieldCode() {
38         return OxmMatchConstants.UDP_DST;
39     }
40
41     @Override
42     protected int getOxmClassCode() {
43         return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
44     }
45
46     @Override
47     protected int getValueLength() {
48         return EncodeConstants.SIZE_OF_SHORT_IN_BYTES;
49     }
50 }