Remove EncodeConstants.SIZE_OF_{BYTE,SHORT,INT,LONG}_IN_BYTES
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / action / OF10SetTpSrcActionDeserializer.java
index b07f69fc625e06f246d735275a8e49f2f54601ef..74c4901fc6a9802f158e8a146ec0876031b33c8a 100644 (file)
@@ -5,12 +5,11 @@
  * 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.protocol.impl.deserialization.action;
 
-import io.netty.buffer.ByteBuf;
+import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16;
 
-import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetTpSrcCaseBuilder;
@@ -20,18 +19,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
 
 /**
- * @author michal.polkorab
+ * OF10SetTpSrcActionDeserializer.
  *
+ * @author michal.polkorab
  */
 public class OF10SetTpSrcActionDeserializer extends AbstractActionDeserializer {
-
     @Override
     public Action deserialize(ByteBuf input) {
-        ActionBuilder builder = new ActionBuilder();
-        input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+        final ActionBuilder builder = new ActionBuilder();
+        input.skipBytes(2 * Short.BYTES);
         SetTpSrcCaseBuilder caseBuilder = new SetTpSrcCaseBuilder();
         SetTpSrcActionBuilder actionBuilder = new SetTpSrcActionBuilder();
-        actionBuilder.setPort(new PortNumber((long) input.readUnsignedShort()));
+        actionBuilder.setPort(new PortNumber(readUint16(input).toUint32()));
         caseBuilder.setSetTpSrcAction(actionBuilder.build());
         builder.setActionChoice(caseBuilder.build());
         input.skipBytes(ActionConstants.PADDING_IN_TP_PORT_ACTION);