public abstract class Validator<T> extends Object
isValid(Object)
and should override
invalidMessage(Object)
.Constructor and Description |
---|
Validator() |
Modifier and Type | Method and 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.
|
abstract boolean |
isValid(T argument)
Checks an argument for validity.
|
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.
|
public final T validate(T argument)
argument
- argument to validateIllegalArgumentException
- if validation failspublic abstract boolean isValid(T argument)
argument
- argument to validatepublic String invalidMessage(T argument)
argument
- argument that failed validationpublic final Validator<T> and(Validator<T> other)
other
- other validatorpublic final Validator<T> or(Validator<T> other)
other
- other validatorCopyright © 2011–2017 The Apache Software Foundation. All rights reserved.