Using the value in the installedSwView data structure to populate
[controller.git] / opendaylight / sal / api / src / main / java / org / opendaylight / controller / sal / match / Match.java
index 30c25af57f688539c7bf569aa4ecccf0f804af26..2c3cfb8303736229e6c86b618642f6bd72b12aaa 100644 (file)
@@ -354,7 +354,7 @@ public class Match implements Cloneable, Serializable {
                         .getSubnetMaskLength(thisMask);
                 int otherMaskLen = (otherMask == null) ? ((otherAddress instanceof Inet4Address) ? 32 : 128) : NetUtils
                         .getSubnetMaskLength(otherMask);
-                if (otherMaskLen < thisMaskLen) {
+                if (thisMaskLen < otherMaskLen) {
                     intersection.setField(new MatchField(type, NetUtils.getSubnetPrefix(otherAddress, otherMaskLen),
                             otherMask));
                 } else {
@@ -441,7 +441,17 @@ public class Match implements Cloneable, Serializable {
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + ((fields == null) ? 0 : fields.hashCode());
+        if (this.fields == null) {
+            result = prime * result;
+        } else {
+            int sum = 0;
+            for (MatchType field : this.fields.keySet()) {
+                MatchField f = this.fields.get(field);
+                sum = sum + ((field==null ? 0 : field.calculateConsistentHashCode()) ^
+                             (f==null ? 0 : f.hashCode()));
+            }
+            result = prime * result + sum;
+        }
         result = prime * result + matches;
         return result;
     }
@@ -473,6 +483,13 @@ public class Match implements Cloneable, Serializable {
 
     @Override
     public String toString() {
-        return "Match[" + fields.values() + "]";
+        StringBuilder builder = new StringBuilder();
+        builder.append("Match [fields=");
+        builder.append(fields);
+        builder.append(", matches=");
+        builder.append(matches);
+        builder.append("]");
+        return builder.toString();
     }
+
 }