Package org.apache.accumulo.core.util
Class Validator<T>
- java.lang.Object
-
- org.apache.accumulo.core.util.Validator<T>
-
- All Implemented Interfaces:
Predicate<T>
public abstract class Validator<T> extends Object implements Predicate<T>
A class that validates arguments of a particular type. Implementations must implementPredicate.test(Object)
and should overrideinvalidMessage(Object)
.
-
-
Constructor Summary
Constructors Constructor Description Validator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Validator<T>
and(Validator<T> other)
Creates a new validator that is the conjunction of this one and the given one.String
invalidMessage(T argument)
Formulates an exception message for invalid values.Validator<T>
not()
Creates a new validator that is the negation of this one.Validator<T>
or(Validator<T> other)
Creates a new validator that is the disjunction of this one and the given one.T
validate(T argument)
Validates an argument.
-
-
-
Method Detail
-
validate
public final T validate(T argument)
Validates an argument.- Parameters:
argument
- argument to validate- Returns:
- the argument, if validation passes
- Throws:
IllegalArgumentException
- if validation fails
-
invalidMessage
public String invalidMessage(T argument)
Formulates an exception message for invalid values.- Parameters:
argument
- argument that failed validation- Returns:
- exception message
-
and
public final Validator<T> and(Validator<T> other)
Creates a new validator that is the conjunction of this one and the given one. An argument passed to the returned validator is valid only if it passes both validators.- Parameters:
other
- other validator- Returns:
- combined validator
-
or
public final Validator<T> or(Validator<T> other)
Creates a new validator that is the disjunction of this one and the given one. An argument passed to the returned validator is valid only if it passes at least one of the validators.- Parameters:
other
- other validator- Returns:
- combined validator
-
-