public boolean evaluate(Object data) throws ValidationException { for (Predicate p : predicates) { if (!p.evaluate(data)) { return false; } } return true; }
public String getDescription() { return "not " + delegate.getDescription(); }
public boolean evaluate(Object data) throws ValidationException { for (Predicate p : predicates) { if (p.evaluate(data)) { return true; } } return false; }
public String getDescription() { return "not " + delegate.getDescription(); }
public boolean evaluate(Object data) throws ValidationException { for (Predicate p : predicates) { if (!p.evaluate(data)) { return false; } } return true; }
public String getDescription() { String or = " or "; StringBuilder b = new StringBuilder(); for (Predicate p : predicates) { b.append(p.getDescription()).append(or); } return b.substring(0, b.length() - or.length()); }
public boolean evaluate(Object data) throws ValidationException { try { return !delegate.evaluate(data); } catch (ValidationException e) { return true; } }
public String getDescription() { String or = " or "; StringBuilder b = new StringBuilder(); for (Predicate p : predicates) { b.append(p.getDescription()).append(or); } return b.substring(0, b.length() - or.length()); }
public boolean evaluate(Object data) throws ValidationException { for (Predicate p : predicates) { if (p.evaluate(data)) { return true; } } return false; }
public String getDescription() { String and = " and "; StringBuilder b = new StringBuilder(); for (Predicate p : predicates) { b.append(p.getDescription()).append(and); } return b.substring(0, b.length() - and.length()); }
public boolean evaluate(Object data) throws ValidationException { try { return !delegate.evaluate(data); } catch (ValidationException e) { return true; } }
public String getDescription() { String and = " and "; StringBuilder b = new StringBuilder(); for (Predicate p : predicates) { b.append(p.getDescription()).append(and); } return b.substring(0, b.length() - and.length()); }
public boolean test(String value) { try { return getPredicate().evaluate(value); } catch (ValidationException e) { return false; } }
/** * Creates a new primitive rule * @param predicate predicate to be used * @param trimmer trimming behavior */ public PredicatePrimitiveTypeRule(Predicate predicate, Trimmer trimmer) { this.predicate = predicate; this.trimmer = trimmer; setDescription("Primitive value '%s' requires to be " + predicate.getDescription()); }
public boolean test(String value) { try { return getPredicate().evaluate(value); } catch (ValidationException e) { return false; } }
/** * Creates a new primitive rule * @param predicate predicate to be used * @param trimmer trimming behavior */ public PredicatePrimitiveTypeRule(Predicate predicate, Trimmer trimmer) { this.predicate = predicate; this.trimmer = trimmer; setDescription("Primitive value '%s' requires to be " + predicate.getDescription()); }
public ValidationException[] apply(String value) { try { return result(getPredicate().evaluate(correct(value)), value); } catch (ValidationException e) { return failed(e); } }
/** * Create a new message rule * @param predicate the predicate to be used for the test * @param expression the expression to be used to extract the message part * to be tested */ public PredicateMessageRule(Predicate predicate, Expression<Message> expression) { this.testPredicate = predicate; this.testExpression = expression; setDescription(testExpression.getDescription() + " '%s' requires to be " + testPredicate.getDescription()); }
public ValidationException[] apply(String value) { try { return result(getPredicate().evaluate(correct(value)), value); } catch (ValidationException e) { return failed(e); } }
/** * Create a new message rule * @param predicate the predicate to be used for the test * @param expression the expression to be used to extract the message part * to be tested */ public PredicateMessageRule(Predicate predicate, Expression<Message> expression) { this.testPredicate = predicate; this.testExpression = expression; setDescription(testExpression.getDescription() + " '%s' requires to be " + testPredicate.getDescription()); }