Bump MRI upstreams
[openflowplugin.git] / openflowjava / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / OF10PortModInputMessageFactory.java
index 025f7ba4053c10393d4a9daad0bbfc2e7b27563d..dce173fd36b52db36539932e57b4ed7dd287e401 100644 (file)
@@ -7,6 +7,9 @@
  */
 package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 
+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.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
@@ -18,48 +21,49 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder;
 
 /**
- * @author giuseppex.petralia@intel.com
+ * Translates PortModInput messages.
  *
+ * @author giuseppex.petralia@intel.com
  */
 public class OF10PortModInputMessageFactory implements OFDeserializer<PortModInput> {
 
     @Override
     public PortModInput deserialize(final ByteBuf rawMessage) {
-        PortModInputBuilder builder = new PortModInputBuilder();
-        builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
-        builder.setXid(rawMessage.readUnsignedInt());
-        builder.setPortNo(new PortNumber((long) rawMessage.readUnsignedShort()));
-        builder.setHwAddress(ByteBufUtils.readIetfMacAddress(rawMessage));
-        builder.setConfigV10(createPortConfig(rawMessage.readUnsignedInt()));
-        builder.setMaskV10(createPortConfig(rawMessage.readUnsignedInt()));
-        builder.setAdvertiseV10(createPortFeatures(rawMessage.readUnsignedInt()));
-        return builder.build();
+        return new PortModInputBuilder()
+                .setVersion(EncodeConstants.OF_VERSION_1_0)
+                .setXid(readUint32(rawMessage))
+                .setPortNo(new PortNumber(readUint16(rawMessage).toUint32()))
+                .setHwAddress(ByteBufUtils.readIetfMacAddress(rawMessage))
+                .setConfigV10(createPortConfig(rawMessage.readUnsignedInt()))
+                .setMaskV10(createPortConfig(rawMessage.readUnsignedInt()))
+                .setAdvertiseV10(createPortFeatures(rawMessage.readUnsignedInt()))
+                .build();
     }
 
     private static PortConfigV10 createPortConfig(final long input) {
-        final Boolean _portDown = ((input) & (1 << 0)) > 0;
-        final Boolean _noStp = ((input) & (1 << 1)) > 0;
-        final Boolean _noRecv = ((input) & (1 << 2)) > 0;
-        final Boolean _noRecvStp = ((input) & (1 << 3)) > 0;
-        final Boolean _noFlood = ((input) & (1 << 4)) > 0;
-        final Boolean _noFwd = ((input) & (1 << 5)) > 0;
-        final Boolean _noPacketIn = ((input) & (1 << 6)) > 0;
+        final Boolean _portDown = (input & 1 << 0) != 0;
+        final Boolean _noStp = (input & 1 << 1) != 0;
+        final Boolean _noRecv = (input & 1 << 2) != 0;
+        final Boolean _noRecvStp = (input & 1 << 3) != 0;
+        final Boolean _noFlood = (input & 1 << 4) != 0;
+        final Boolean _noFwd = (input & 1 << 5) != 0;
+        final Boolean _noPacketIn = (input & 1 << 6) != 0;
         return new PortConfigV10(_noFlood, _noFwd, _noPacketIn, _noRecv, _noRecvStp, _noStp, _portDown);
     }
 
     private static PortFeaturesV10 createPortFeatures(final long input) {
-        final Boolean _10mbHd = ((input) & (1 << 0)) > 0;
-        final Boolean _10mbFd = ((input) & (1 << 1)) > 0;
-        final Boolean _100mbHd = ((input) & (1 << 2)) > 0;
-        final Boolean _100mbFd = ((input) & (1 << 3)) > 0;
-        final Boolean _1gbHd = ((input) & (1 << 4)) > 0;
-        final Boolean _1gbFd = ((input) & (1 << 5)) > 0;
-        final Boolean _10gbFd = ((input) & (1 << 6)) > 0;
-        final Boolean _copper = ((input) & (1 << 7)) > 0;
-        final Boolean _fiber = ((input) & (1 << 8)) > 0;
-        final Boolean _autoneg = ((input) & (1 << 9)) > 0;
-        final Boolean _pause = ((input) & (1 << 10)) > 0;
-        final Boolean _pauseAsym = ((input) & (1 << 11)) > 0;
+        final Boolean _10mbHd = (input & 1 << 0) != 0;
+        final Boolean _10mbFd = (input & 1 << 1) != 0;
+        final Boolean _100mbHd = (input & 1 << 2) != 0;
+        final Boolean _100mbFd = (input & 1 << 3) != 0;
+        final Boolean _1gbHd = (input & 1 << 4) != 0;
+        final Boolean _1gbFd = (input & 1 << 5) != 0;
+        final Boolean _10gbFd = (input & 1 << 6) != 0;
+        final Boolean _copper = (input & 1 << 7) != 0;
+        final Boolean _fiber = (input & 1 << 8) != 0;
+        final Boolean _autoneg = (input & 1 << 9) != 0;
+        final Boolean _pause = (input & 1 << 10) != 0;
+        final Boolean _pauseAsym = (input & 1 << 11) != 0;
         return new PortFeaturesV10(_100mbFd, _100mbHd, _10gbFd, _10mbFd, _10mbHd, _1gbFd, _1gbHd, _autoneg, _copper,
                 _fiber, _pause, _pauseAsym);
     }