01: package org.jreform.criteria;
02:
03: import org.jreform.Criterion;
04:
05: /**
06: * Checks if string is equal to one of the passed in strings.
07: *
08: * @author armandino (at) gmail.com
09: */
10: public final class AcceptString extends Accept<String> {
11: private boolean caseSensitive = true;
12:
13: AcceptString(String... values) {
14: super (values);
15: }
16:
17: protected boolean areEqual(String v1, String v2) {
18: if (caseSensitive)
19: return super .areEqual(v1, v2);
20:
21: return v1.equalsIgnoreCase(v2);
22: }
23:
24: /**
25: * Specifies string comparison to be case-insensitive.
26: */
27: public Criterion<String> ignoreCase() {
28: caseSensitive = false;
29: return this;
30: }
31:
32: }
|