X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fsal%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fmatch%2FMatch.java;h=2c3cfb8303736229e6c86b618642f6bd72b12aaa;hp=30c25af57f688539c7bf569aa4ecccf0f804af26;hb=81754b97dad4d38ee9a38516664f6b1b8c99d48c;hpb=144cfa4b4a926b7d0c3d5f60ada050c609762699 diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/match/Match.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/match/Match.java index 30c25af57f..2c3cfb8303 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/match/Match.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/match/Match.java @@ -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(); } + }