Update MRI upstreams for Phosphorus
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / util / CodeKeyMakerFactory.java
index ba692c8f81a629692b08d43e522c686e258a2cf8..651f2385e0a6e0da64d5a340cd83d398fcf8efef 100644 (file)
@@ -9,7 +9,6 @@
 package org.opendaylight.openflowjava.protocol.impl.util;
 
 import io.netty.buffer.ByteBuf;
-
 import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionDeserializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionDeserializerKey;
@@ -17,33 +16,31 @@ import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKe
 import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;
 import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint8;
 
 /**
- * @author michal.polkorab
+ * Factory for creating CodeKeyMaker instances.
  *
+ * @author michal.polkorab
  */
-public abstract class CodeKeyMakerFactory {
+public final class CodeKeyMakerFactory {
 
     private CodeKeyMakerFactory() {
         //not called
     }
-    /**
-     * @param version
-     * @return
-     */
-    public static CodeKeyMaker createMatchEntriesKeyMaker(short version) {
+
+    public static CodeKeyMaker createMatchEntriesKeyMaker(final Uint8 version) {
         return new AbstractCodeKeyMaker(version) {
             @Override
-            public MessageCodeKey make(ByteBuf input) {
+            public MessageCodeKey make(final ByteBuf input) {
                 int oxmClass = input.getUnsignedShort(input.readerIndex());
-                int oxmField = input.getUnsignedByte(input.readerIndex()
-                        + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1;
+                int oxmField = input.getUnsignedByte(input.readerIndex() + Short.BYTES) >>> 1;
                 MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(getVersion(),
                         oxmClass, oxmField);
                 if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) {
-                    long expId = input.getUnsignedInt(input.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES
-                            + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
-                    key.setExperimenterId(expId);
+                    long expId = input.getUnsignedInt(input.readerIndex() + Short.BYTES + 2 * Byte.BYTES);
+                    key.setExperimenterId(Uint32.valueOf(expId));
                     return key;
                 }
                 key.setExperimenterId(null);
@@ -52,18 +49,13 @@ public abstract class CodeKeyMakerFactory {
         };
     }
 
-    /**
-     * @param version
-     * @return
-     */
-    public static CodeKeyMaker createActionsKeyMaker(short version) {
+    public static CodeKeyMaker createActionsKeyMaker(final Uint8 version) {
         return new AbstractCodeKeyMaker(version) {
             @Override
-            public MessageCodeKey make(ByteBuf input) {
+            public MessageCodeKey make(final ByteBuf input) {
                 int type = input.getUnsignedShort(input.readerIndex());
                 if (type == EncodeConstants.EXPERIMENTER_VALUE) {
-                    Long expId = input.getUnsignedInt(input.readerIndex()
-                            + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+                    Long expId = input.getUnsignedInt(input.readerIndex() + 2 * Short.BYTES);
                     return new ExperimenterActionDeserializerKey(getVersion(), expId);
                 }
                 ActionDeserializerKey actionDeserializerKey = new ActionDeserializerKey(getVersion(), type, null);
@@ -72,18 +64,13 @@ public abstract class CodeKeyMakerFactory {
         };
     }
 
-    /**
-     * @param version
-     * @return
-     */
-    public static CodeKeyMaker createInstructionsKeyMaker(short version) {
+    public static CodeKeyMaker createInstructionsKeyMaker(final Uint8 version) {
         return new AbstractCodeKeyMaker(version) {
             @Override
-            public MessageCodeKey make(ByteBuf input) {
+            public MessageCodeKey make(final ByteBuf input) {
                 int type = input.getUnsignedShort(input.readerIndex());
                 if (type == EncodeConstants.EXPERIMENTER_VALUE) {
-                    Long expId = input.getUnsignedInt(input.readerIndex()
-                            + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+                    Long expId = input.getUnsignedInt(input.readerIndex() + 2 * Short.BYTES);
                     return new ExperimenterInstructionDeserializerKey(getVersion(), expId);
                 }
                 return new InstructionDeserializerKey(getVersion(), type, null);