Rule implements JsonObjectConvertible { @Override public boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Rule rule = (Rule) o; return type == rule.type && pattern.pattern().equals(rule.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 testEquals() { final Rule newAllow = new Rule(Rules.DEFAULT_ALLOW.getType(), Rules.DEFAULT_ALLOW.getPattern()); assertEquals("DEFAULT_ALLOW should equal new rule with same params as DEFAULT_ALLOW", Rules.DEFAULT_ALLOW, newAllow); assertNotEquals("DEFAULT_ALLOW should not equal new ALLOW rule with different pattern", Rules.DEFAULT_ALLOW, new Rule(Rules.DEFAULT_ALLOW.getType(), Pattern.compile("foo"))); assertNotEquals("DEFAULT_DENY should not equal new ALLOW rule with same params as DEFAULT_ALLOW", Rules.DEFAULT_DENY, newAllow); assertNotEquals("DEFAULT_INCLUDE should not equal new ALLOW rule with same params as DEFAULT_ALLOW", Rules.DEFAULT_INCLUDE, newAllow); }