@Test public void testEqualsComparison() { NeutralCriteria neutralCriteria1 = new NeutralCriteria("key", "=", "value"); NeutralCriteria neutralCriteria2 = new NeutralCriteria("key", "=", "value"); NeutralCriteria neutralCriteria3 = new NeutralCriteria("differentKey", "=", "value"); NeutralCriteria neutralCriteria4 = new NeutralCriteria("key", "!=", "value"); NeutralCriteria neutralCriteria5 = new NeutralCriteria("key", "!=", "differentValue"); NeutralCriteria neutralCriteria6 = new NeutralCriteria("key", "=", "value", true); NeutralCriteria neutralCriteria7 = new NeutralCriteria("key", "=", "value", false); assertTrue(neutralCriteria1.equals(neutralCriteria2)); assertFalse(neutralCriteria1 == neutralCriteria2); assertFalse(neutralCriteria1.equals(neutralCriteria3)); assertFalse(neutralCriteria1.equals(neutralCriteria4)); assertFalse(neutralCriteria1.equals(neutralCriteria5)); assertTrue(neutralCriteria1.equals(neutralCriteria6)); assertFalse(neutralCriteria1.equals(neutralCriteria7)); }
@Override public boolean equals(Object o) { if (o instanceof NeutralCriteria) { NeutralCriteria nc = (NeutralCriteria) o; boolean keysMatch = this.valuesMatch(this.key, nc.key); boolean operatorsMatch = this.valuesMatch(this.operator, nc.operator); boolean valuesMatch = this.valuesMatch(this.value, nc.value); boolean prefixesMatch = (this.canBePrefixed == nc.canBePrefixed); boolean typeMatch = ( this.getType() == nc.getType() ); boolean removableMatch = (this.isRemovable() == nc.isRemovable()); return (keysMatch && operatorsMatch && valuesMatch && prefixesMatch && typeMatch && removableMatch); } return false; }
NeutralCriteria { @Override public boolean equals(Object o) { if (o instanceof NeutralCriteria) { NeutralCriteria nc = (NeutralCriteria) o; boolean keysMatch = this.valuesMatch(this.key, nc.key); boolean operatorsMatch = this.valuesMatch(this.operator, nc.operator); boolean valuesMatch = this.valuesMatch(this.value, nc.value); boolean prefixesMatch = (this.canBePrefixed == nc.canBePrefixed); boolean typeMatch = ( this.getType() == nc.getType() ); boolean removableMatch = (this.isRemovable() == nc.isRemovable()); return (keysMatch && operatorsMatch && valuesMatch && prefixesMatch && typeMatch && removableMatch); } return false; } }
NeutralCriteria { @Override public boolean equals(Object o) { if (o instanceof NeutralCriteria) { NeutralCriteria nc = (NeutralCriteria) o; boolean keysMatch = this.valuesMatch(this.key, nc.key); boolean operatorsMatch = this.valuesMatch(this.operator, nc.operator); boolean valuesMatch = this.valuesMatch(this.value, nc.value); boolean prefixesMatch = (this.canBePrefixed == nc.canBePrefixed); boolean typeMatch = ( this.getType() == nc.getType() ); boolean removableMatch = (this.isRemovable() == nc.isRemovable()); return (keysMatch && operatorsMatch && valuesMatch && prefixesMatch && typeMatch && removableMatch); } return false; } NeutralCriteria(String criteria);  NeutralCriteria(String newKey, String newOperator, Object newValue);  NeutralCriteria(String newKey, String newOperator, Object newValue, boolean canBePrefixed); }
NeutralCriteria { @Override public boolean equals(Object o) { if (o instanceof NeutralCriteria) { NeutralCriteria nc = (NeutralCriteria) o; boolean keysMatch = this.valuesMatch(this.key, nc.key); boolean operatorsMatch = this.valuesMatch(this.operator, nc.operator); boolean valuesMatch = this.valuesMatch(this.value, nc.value); boolean prefixesMatch = (this.canBePrefixed == nc.canBePrefixed); boolean typeMatch = ( this.getType() == nc.getType() ); boolean removableMatch = (this.isRemovable() == nc.isRemovable()); return (keysMatch && operatorsMatch && valuesMatch && prefixesMatch && typeMatch && removableMatch); } return false; } NeutralCriteria(String criteria);  NeutralCriteria(String newKey, String newOperator, Object newValue);  NeutralCriteria(String newKey, String newOperator, Object newValue, boolean canBePrefixed); @SuppressWarnings("PMD.UselessOverridingMethod") // this is overridden because equals is also overridden @Override int hashCode(); String getKey(); String getOperator(); Object getValue(); void setKey(String key); void setOperator(String operator); void setValue(Object value); boolean canBePrefixed(); void setCanBePrefixed(boolean canBePrefixed); @Override String toString(); @Override boolean equals(Object o); SearchType getType(); void setType(SearchType type); boolean isRemovable(); void setRemovable(boolean removable); }
NeutralCriteria { @Override public boolean equals(Object o) { if (o instanceof NeutralCriteria) { NeutralCriteria nc = (NeutralCriteria) o; boolean keysMatch = this.valuesMatch(this.key, nc.key); boolean operatorsMatch = this.valuesMatch(this.operator, nc.operator); boolean valuesMatch = this.valuesMatch(this.value, nc.value); boolean prefixesMatch = (this.canBePrefixed == nc.canBePrefixed); boolean typeMatch = ( this.getType() == nc.getType() ); boolean removableMatch = (this.isRemovable() == nc.isRemovable()); return (keysMatch && operatorsMatch && valuesMatch && prefixesMatch && typeMatch && removableMatch); } return false; } NeutralCriteria(String criteria);  NeutralCriteria(String newKey, String newOperator, Object newValue);  NeutralCriteria(String newKey, String newOperator, Object newValue, boolean canBePrefixed); @SuppressWarnings("PMD.UselessOverridingMethod") // this is overridden because equals is also overridden @Override int hashCode(); String getKey(); String getOperator(); Object getValue(); void setKey(String key); void setOperator(String operator); void setValue(Object value); boolean canBePrefixed(); void setCanBePrefixed(boolean canBePrefixed); @Override String toString(); @Override boolean equals(Object o); SearchType getType(); void setType(SearchType type); boolean isRemovable(); void setRemovable(boolean removable); static final String CRITERIA_IN; static final String CRITERIA_REGEX; static final String CRITERIA_GT; static final String CRITERIA_GTE; static final String CRITERIA_LT; static final String CRITERIA_LTE; static final String OPERATOR_EQUAL; static final String CRITERIA_EXISTS; }