@Test public void shouldBeConsideredEqualIfFieldNameIsEqual() { RequiredFieldValidator fieldValidator = new RequiredFieldValidator("name", ""); RequiredFieldValidator equalFieldValidator = new RequiredFieldValidator("name", ""); RequiredFieldValidator differentFieldValidator = new RequiredFieldValidator("Name", ""); RequiredFieldValidator anotherDifferentFieldValidator = new RequiredFieldValidator("someOtherField", ""); assertTrue(fieldValidator.equals(fieldValidator)); assertTrue(fieldValidator.equals(equalFieldValidator)); assertFalse(fieldValidator.equals(differentFieldValidator)); assertFalse(fieldValidator.equals(anotherDifferentFieldValidator)); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } RequiredFieldValidator that = (RequiredFieldValidator) o; return fieldName.equals(that.fieldName); }
RequiredFieldValidator implements AbstractValidator { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } RequiredFieldValidator that = (RequiredFieldValidator) o; return fieldName.equals(that.fieldName); } }
RequiredFieldValidator implements AbstractValidator { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } RequiredFieldValidator that = (RequiredFieldValidator) o; return fieldName.equals(that.fieldName); } RequiredFieldValidator(String fieldName, String fieldValue); }
RequiredFieldValidator implements AbstractValidator { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } RequiredFieldValidator that = (RequiredFieldValidator) o; return fieldName.equals(that.fieldName); } RequiredFieldValidator(String fieldName, String fieldValue); @Override void validate(StartupForm target, List<String> errors, ConfigSource configSource); @Override boolean equals(Object o); @Override int hashCode(); }
RequiredFieldValidator implements AbstractValidator { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } RequiredFieldValidator that = (RequiredFieldValidator) o; return fieldName.equals(that.fieldName); } RequiredFieldValidator(String fieldName, String fieldValue); @Override void validate(StartupForm target, List<String> errors, ConfigSource configSource); @Override boolean equals(Object o); @Override int hashCode(); static final String ERROR_REQUIRED; }