com.ehsbe.commons.util
Class MultiValidator<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<Validator<E>>
com.ehsbe.commons.util.MultiValidator<E>
- Type Parameters:
E
- type of input to validate
- All Implemented Interfaces:
- Validator<E>, Serializable, Cloneable, Iterable<Validator<E>>, Collection<Validator<E>>, List<Validator<E>>, RandomAccess
public class MultiValidator<E>
- extends ArrayList<Validator<E>>
- implements Validator<E>
A Validator, which consist of several other validators of the same kind
to verify a certain input.
The order of the validators is important, since shortcut outcome combination
is always done on accept.
- Version:
- $Revision: 432 $
- Author:
- Jens Elkner
- See Also:
- Serialized Form
Method Summary |
boolean |
accept(E input)
Check, whether the given input is valid and would be accepted. |
void |
setValidationType(boolean and)
Set the method for the combination of all validator outcomes. |
Methods inherited from class java.util.ArrayList |
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize |
MultiValidator
public MultiValidator()
- Create a new Validator
AND
validator.
MultiValidator
public MultiValidator(boolean and)
- Create a new Validator.
- Parameters:
and
- If true
combine the outcome of the
validators with AND
. Otherwise combine it with
OR
.
accept
public boolean accept(E input)
- Check, whether the given input is valid and would be accepted.
- Specified by:
accept
in interface Validator<E>
- Parameters:
input
- the value to check. Might be null
.
- Returns:
true
if the input should is accepted.
setValidationType
public void setValidationType(boolean and)
- Set the method for the combination of all validator outcomes.
- Parameters:
and
- if true
, combine the outcome of the validators
with AND
, otherwise combine them with OR
.
Copyright ©2005-2009 EHSBE, Walther-Rathenau-Str. 58, 39104 Magdeburg, Sachsen-Anhalt, Germany. All Rights Reserved.