MatchesRuleExecutor implements RuleExecutor<Object, Object> { @Override public boolean validate(Object model, Object argument) throws Exception { if (ValidationRulesUtils.isEmpty(model) && ValidationRulesUtils.isEmpty(argument)) { return true; } else if (ValidationRulesUtils.isEmpty(model) || ValidationRulesUtils.isEmpty(argument)) { return false; } else if (model == argument || model.equals(argument) || String.valueOf(model).equals(String.valueOf(argument))) { return true; } else { return false; } }  @Override boolean validate(Object model, Object argument);  }
@Test public void testValidate() throws Exception { MatchesRuleExecutor executor = new MatchesRuleExecutor(); assertTrue(executor.validate(null, null)); assertTrue(executor.validate("Dave", "Dave")); assertTrue(executor.validate("124124", "124124")); assertFalse(executor.validate("Dave", "dave")); assertTrue(executor.validate(123, "123")); assertFalse(executor.validate("124124", "124123")); assertFalse(executor.validate("Dave", "Dive")); assertFalse(executor.validate("124124", "124-124")); assertFalse(executor.validate(123, "1234")); assertFalse(executor.validate("", "1234")); }