/** * 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(Message msg) { try { Object subject = testExpression.evaluate(msg); boolean passed = getPredicate().evaluate(subject); return passed ? passed() : failedWithValue(subject, testExpression.getLocation(msg)); } catch (Exception e) { return failed(e); } }
public ValidationException[] apply(Message msg) { try { Object subject = testExpression.evaluate(msg); boolean passed = getPredicate().evaluate(subject); return passed ? passed() : failedWithValue(subject, testExpression.getLocation(msg)); } catch (Exception 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()); }