Cleanup MatchUtil
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / util / NodeConnectorRefToPortTranslator.java
index a71d5804451e63e0949b3ab3f4a87e803702ab78..4d00092816ec222ab4435a73cbe0f53a540e3d11 100644 (file)
@@ -9,10 +9,9 @@ package org.opendaylight.openflowplugin.impl.util;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
-import java.math.BigInteger;
 import java.util.List;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
@@ -25,6 +24,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketIn;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
 
 /**
  * Created by Tomas Slusny on 23.3.2016.
@@ -41,11 +42,11 @@ public final class NodeConnectorRefToPortTranslator {
      * @return packet input converted to node connector reference
      */
     @Nullable
-    public static NodeConnectorRef toNodeConnectorRef(@Nonnull PacketIn packetIn, BigInteger dataPathId) {
+    public static NodeConnectorRef toNodeConnectorRef(@NonNull final PacketIn packetIn, final Uint64 dataPathId) {
         Preconditions.checkNotNull(packetIn);
 
         NodeConnectorRef ref = null;
-        Long port = getPortNoFromPacketIn(packetIn);
+        Uint32 port = getPortNoFromPacketIn(packetIn);
 
         if (port != null) {
             OpenflowVersion version = OpenflowVersion.get(packetIn.getVersion());
@@ -64,10 +65,10 @@ public final class NodeConnectorRefToPortTranslator {
      */
     @SuppressWarnings("unchecked")
     @Nullable
-    public static Long fromNodeConnectorRef(@Nonnull NodeConnectorRef nodeConnectorRef, short version) {
+    public static Uint32 fromNodeConnectorRef(@NonNull final NodeConnectorRef nodeConnectorRef, final short version) {
         Preconditions.checkNotNull(nodeConnectorRef);
 
-        Long port = null;
+        Uint32 port = null;
 
         final InstanceIdentifier<?> value = nodeConnectorRef.getValue();
         if (value instanceof KeyedInstanceIdentifier) {
@@ -85,14 +86,14 @@ public final class NodeConnectorRefToPortTranslator {
 
     @VisibleForTesting
     @Nullable
-    static Long getPortNoFromPacketIn(@Nonnull PacketIn packetIn) {
+    static Uint32 getPortNoFromPacketIn(@NonNull final PacketIn packetIn) {
         Preconditions.checkNotNull(packetIn);
 
-        Long port = null;
+        Uint32 port = null;
 
-        if (packetIn.getVersion() == OFConstants.OFP_VERSION_1_0 && packetIn.getInPort() != null) {
-            port = packetIn.getInPort().longValue();
-        } else if (packetIn.getVersion() == OFConstants.OFP_VERSION_1_3) {
+        if (packetIn.getVersion().toJava() == OFConstants.OFP_VERSION_1_0 && packetIn.getInPort() != null) {
+            port = Uint32.valueOf(packetIn.getInPort());
+        } else if (packetIn.getVersion().toJava() == OFConstants.OFP_VERSION_1_3) {
             if (packetIn.getMatch() != null && packetIn.getMatch().getMatchEntry() != null) {
                 List<MatchEntry> entries = packetIn.getMatch().getMatchEntry();