01: package org.jreform.criteria;
02:
03: import org.jreform.Criterion;
04:
05: /**
06: * Performs an <tt>OR</tt> over all criteria on the given value.
07: *
08: * @author armandino (at) gmail.com
09: */
10: public final class Or<T> extends AbstractCriterion<T> {
11: private Criterion<T>[] criteria;
12:
13: Or(Criterion<T>... criteria) {
14: if (criteria.length < 2)
15: throw new IllegalArgumentException(getClass().getName()
16: + " requires at least two criteria");
17:
18: this .criteria = criteria;
19: }
20:
21: protected boolean verify(T value) {
22: for (Criterion<T> criterion : criteria) {
23: if (criterion.isSatisfied(value))
24: return true;
25: }
26:
27: return false;
28: }
29:
30: protected String generateErrorMessage() {
31: return "Invalid input value";
32: }
33:
34: }
|