Rule implements JsonObjectConvertible { @Override public int hashCode() { return Objects.hash(type, pattern.pattern()); } Rule(final RuleType type, final Pattern pattern); @NotNull static JsonKeys keys(); RuleType getType(); Pattern getPattern(); boolean isInclude(); boolean isExclude(); boolean isAllow(); boolean isDeny(); boolean matches(String value); @Override JsonObject toJson(); @Override String toString(); @Override boolean equals(final Object o); @Override int hashCode();  }
@Test public void testHashCode() { final Rule newAllow = new Rule(Rules.DEFAULT_ALLOW.getType(), Rules.DEFAULT_ALLOW.getPattern()); assertEquals("hashCode(): DEFAULT_ALLOW should equal new rule with same params as DEFAULT_ALLOW", Rules.DEFAULT_ALLOW.hashCode(), newAllow.hashCode()); assertNotEquals("hashCode(): DEFAULT_ALLOW should not equal new ALLOW rule with different pattern", Rules.DEFAULT_ALLOW.hashCode(), new Rule(Rules.DEFAULT_ALLOW.getType(), Pattern.compile("foo")).hashCode()); assertNotEquals("hashCode(): DEFAULT_DENY should not equal new ALLOW rule with same params as DEFAULT_ALLOW", Rules.DEFAULT_DENY.hashCode(), newAllow.hashCode()); assertNotEquals("hashCode(): DEFAULT_INCLUDE should not equal new ALLOW rule with same params as DEFAULT_ALLOW", Rules.DEFAULT_INCLUDE.hashCode(), newAllow.hashCode()); }