Migrate uint/ByteBuf interactions
[openflowplugin.git] / extension / openflowjava-extension-nicira / src / main / java / org / opendaylight / openflowjava / nx / codec / match / NshFlagsCodec.java
index e0fac69af4bb518660fc2e039f57203f4180279d..7fb4772b41e6944434c1c95b4ea7b6de4da66099 100644 (file)
@@ -8,6 +8,8 @@
 
 package org.opendaylight.openflowjava.nx.codec.match;
 
+import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8;
+
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.nx.api.NiciraConstants;
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
@@ -21,6 +23,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev14
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.NxExpMatchEntryValue;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshFlagsCaseValue;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshFlagsCaseValueBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint8;
 
 public class NshFlagsCodec extends AbstractExperimenterMatchCodec {
 
@@ -54,14 +58,15 @@ public class NshFlagsCodec extends AbstractExperimenterMatchCodec {
 
     @Override
     protected NxExpMatchEntryValue deserializeValue(ByteBuf message, boolean hasMask) {
-        Short flagsValue = message.readUnsignedByte();
-        Short maskValue = hasMask ? message.readUnsignedByte() : null;
-        NshFlagsValues flagsValues = new NshFlagsValuesBuilder().setNshFlags(flagsValue).setMask(maskValue).build();
-        return new NshFlagsCaseValueBuilder().setNshFlagsValues(flagsValues).build();
+        Uint8 flagsValue = readUint8(message);
+        Uint8 maskValue = hasMask ? readUint8(message) : null;
+        return new NshFlagsCaseValueBuilder()
+                .setNshFlagsValues(new NshFlagsValuesBuilder().setNshFlags(flagsValue).setMask(maskValue).build())
+                .build();
     }
 
     @Override
-    protected long getExperimenterId() {
+    protected Uint32 getExperimenterId() {
         return NiciraConstants.NX_NSH_VENDOR_ID;
     }
 
@@ -69,9 +74,9 @@ public class NshFlagsCodec extends AbstractExperimenterMatchCodec {
     protected void serializeValue(NxExpMatchEntryValue value, boolean hasMask, ByteBuf outBuffer) {
         NshFlagsCaseValue nshFlagsCaseValue = (NshFlagsCaseValue) value;
         NshFlagsValues nshFlagsValues = nshFlagsCaseValue.getNshFlagsValues();
-        outBuffer.writeByte(nshFlagsValues.getNshFlags());
+        outBuffer.writeByte(nshFlagsValues.getNshFlags().toJava());
         if (hasMask) {
-            outBuffer.writeByte(nshFlagsValues.getMask());
+            outBuffer.writeByte(nshFlagsValues.getMask().toJava());
         }
     }
 }