Merge "Removed getClass comparison if FlowComparator."
[controller.git] / opendaylight / md-sal / statistics-manager / src / main / java / org / opendaylight / controller / md / statistics / manager / FlowComparator.java
index af61db1a8096874945fe92f7fc5478c948b0f5da..2b67edfd9d318d29cbd3508c17a1e8bafd9f4a70 100644 (file)
@@ -32,7 +32,7 @@ final class FlowComparator {
     }
 
     public static boolean flowEquals(Flow statsFlow, Flow storedFlow) {
-        if (statsFlow.getClass() != storedFlow.getClass()) {
+        if (statsFlow == null || storedFlow == null) {
             return false;
         }
         if (statsFlow.getContainerName()== null) {
@@ -42,19 +42,18 @@ final class FlowComparator {
         } else if(!statsFlow.getContainerName().equals(storedFlow.getContainerName())) {
             return false;
         }
-        if (statsFlow.getMatch()== null) {
-            if (storedFlow.getMatch() != null) {
+        if (storedFlow.getPriority() == null) {
+            if (statsFlow.getPriority() != null && statsFlow.getPriority()!= 0x8000) {
                 return false;
             }
-        } //else if(!statsFlow.getMatch().equals(storedFlow.getMatch())) {
-        else if(!matchEquals(statsFlow.getMatch(), storedFlow.getMatch())) {
+        } else if(!statsFlow.getPriority().equals(storedFlow.getPriority())) {
             return false;
         }
-        if (storedFlow.getPriority() == null) {
-            if (statsFlow.getPriority() != null && statsFlow.getPriority()!= 0x8000) {
+        if (statsFlow.getMatch()== null) {
+            if (storedFlow.getMatch() != null) {
                 return false;
             }
-        } else if(!statsFlow.getPriority().equals(storedFlow.getPriority())) {
+        } else if(!matchEquals(statsFlow.getMatch(), storedFlow.getMatch())) {
             return false;
         }
         if (statsFlow.getTableId() == null) {
@@ -95,9 +94,8 @@ final class FlowComparator {
         if (statsFlow == storedFlow) {
             return true;
         }
-        if (storedFlow.getClass() != statsFlow.getClass()) {
-            return false;
-        }
+        if (storedFlow == null && statsFlow != null) return false;
+        if (statsFlow == null && storedFlow != null) return false;
         if (storedFlow.getEthernetMatch() == null) {
             if (statsFlow.getEthernetMatch() != null) {
                 return false;