+ public int valueHashCode(Object o) {
+ if (o == null) {
+ return 0;
+ }
+ switch (this) {
+ case DL_SRC:
+ case DL_DST:
+ return NetUtils.byteArray4ToInt((byte[])o);
+ default:
+ return o.hashCode();
+ }
+ }
+
+ public int hashCode(Object v, Object m) {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + this.hashCode();
+
+ switch (this) {
+ case DL_SRC:
+ case DL_DST:
+ result = prime * result + ((v == null)? 0 : NetUtils.byteArray4ToInt((byte[])v));
+ result = prime * result + ((m == null)? 0 : NetUtils.byteArray4ToInt((byte[])m));
+ break;
+ case NW_SRC:
+ case NW_DST:
+ // Hash code has to take into account only prefix address
+ InetAddress ip = (InetAddress) v;
+ int maskLen = (m == null) ? ((ip instanceof Inet4Address) ? 32 : 128) : NetUtils
+ .getSubnetMaskLength((InetAddress) m);
+ InetAddress prefix = NetUtils.getSubnetPrefix(ip, maskLen);
+ result = prime * result + ((v == null)? 0 : prefix.hashCode());
+ break;
+ default:
+ result = prime * result + ((v == null)? 0 : v.hashCode());
+ result = prime * result + ((m == null)? 0 : m.hashCode());
+ }
+ return result;
+ }