Migrate uint/ByteBuf interactions
[openflowplugin.git] / extension / openflowjava-extension-nicira / src / main / java / org / opendaylight / openflowjava / nx / codec / action / OutputRegCodec.java
index a959fe0d8f0f01fcf01028d3bb2d3d7034628914..a10fcf026e7720a84ebc7806df444e33adc0f482 100644 (file)
@@ -1,13 +1,15 @@
-/**
+/*
  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.openflowjava.nx.codec.action;
 
+import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16;
+import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32;
+
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.nx.api.NiciraActionDeserializerKey;
 import org.opendaylight.openflowjava.nx.api.NiciraActionSerializerKey;
@@ -19,7 +21,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev1
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.output.reg.grouping.NxActionOutputRegBuilder;
 
 /**
- * Codec for the Nicira OutputRegAction
+ * Codec for the Nicira OutputRegAction.
  *
  * @author readams
  */
@@ -34,7 +36,7 @@ public class OutputRegCodec extends AbstractActionCodec {
 
     @Override
     public void serialize(final Action input, final ByteBuf outBuffer) {
-        ActionOutputReg action = ((ActionOutputReg) input.getActionChoice());
+        ActionOutputReg action = (ActionOutputReg) input.getActionChoice();
         serializeHeader(LENGTH, SUBTYPE, outBuffer);
         outBuffer.writeShort(action.getNxActionOutputReg().getNBits().shortValue());
         outBuffer.writeInt(action.getNxActionOutputReg().getSrc().intValue());
@@ -44,12 +46,12 @@ public class OutputRegCodec extends AbstractActionCodec {
 
     @Override
     public Action deserialize(final ByteBuf message) {
-        ActionBuilder actionBuilder = deserializeHeader(message);
-        ActionOutputRegBuilder builder = new ActionOutputRegBuilder();
+        final ActionBuilder actionBuilder = deserializeHeader(message);
+        final ActionOutputRegBuilder builder = new ActionOutputRegBuilder();
         NxActionOutputRegBuilder nxActionOutputRegBuilder = new NxActionOutputRegBuilder();
-        nxActionOutputRegBuilder.setNBits(message.readUnsignedShort());
-        nxActionOutputRegBuilder.setSrc(message.readUnsignedInt());
-        nxActionOutputRegBuilder.setMaxLen(message.readUnsignedShort());
+        nxActionOutputRegBuilder.setNBits(readUint16(message));
+        nxActionOutputRegBuilder.setSrc(readUint32(message));
+        nxActionOutputRegBuilder.setMaxLen(readUint16(message));
         message.skipBytes(PADDING_IN_OUTPUT_REG_ACTION);
         builder.setNxActionOutputReg(nxActionOutputRegBuilder.build());
         actionBuilder.setActionChoice(builder.build());