Package cdc.validation.checkers
Interface Checker<T>
- Type Parameters:
T- The value type.
- All Superinterfaces:
Predicate<T>
- All Known Implementing Classes:
AbstractStringChecker,HasNoDoubleSpaces,HasNoInnerSpaces,HasNoOuterSpaces,HasNoOuterWhiteSpaces,HasNoSpaces,IsConvertibleUsing,IsExistingDirectory,IsExistingFile,IsGreaterOrEqual,IsGreaterThan,IsInRange,IsInstanceOf,IsLessOrEqual,IsLessThan,IsNotNull,IsNull,IsNullOrEmpty,IsPattern,IsXml10String,LengthIsInRange,MatchesPattern,RawRefChecker,RefChecker
Extension of Predicate that explains results.
- Author:
- Damien Carbonne
-
Method Summary
Modifier and TypeMethodDescriptiondefault <S> Checker<S>Creates a checkers that checks that a value is convertible from a source type to a target type, then matches a checker of the target type.default <S> Checker<S>Creates a checkers that checks that a value is convertible from a source type to a target type, then matches a checker of the target type.default Checker<?>Returns a checker that is the logical AND composition of this checker with another one.default <V> Checker<V>default Stringexplain()Explains the conditions at which a positive or negative result is obtained.default Stringstatic <S> Checker<S>fromConverter(Converter<S, ?> converter) Creates a checker from a converter.static <S,T> Checker<S> fromFunction(Function<S, ?> function, Class<S> sourceClass, Class<T> targetClass) Creates a checker from a function.negate()Returns a checker that is the logical OR composition of this checker with another one.booleandefault StringtestAndExplain(T value) Tests a value and explains the result.default StringtestAndExplain(T value, String arg) Tests a value and explains the result.default StringtestAndExplainRaw(Object value) default StringtestAndExplainRaw(Object value, String arg) default booleandefault String
-
Method Details
-
getValueClass
- Returns:
- The class of tested values.
-
test
-
testRaw
-
explain
Explains the conditions at which a positive or negative result is obtained.- Parameters:
result- The result to explain.arg- The argument name to use in explanations.- Returns:
- A string explaining the conditions leading to
result.
-
explain
-
explain
-
testAndExplain
Tests a value and explains the result.- Parameters:
value- The tested value.arg- The argument name to use in explanations.- Returns:
- A string explaining why
valuepasses or fails the test.valueis represented byarg.
-
testAndExplainRaw
-
testAndExplain
Tests a value and explains the result.- Parameters:
value- The tested value.- Returns:
- A string explaining why
valuepasses or fails the test.valueis represented by its default string representation.
-
testAndExplainRaw
-
negate
-
and
Returns a checker that is the logical AND composition of this checker with another one.This checker is evaluated before
other.
If this checker evaluates tofalse,otheris not evaluated.- Parameters:
other- The other checker.- Returns:
- A checker that is the logical AND composition of this checker
with
other.
-
cast
-
cast
-
andRaw
-
orRaw
-
or
Returns a checker that is the logical OR composition of this checker with another one.This checker is evaluated before
other.
If this checker evaluates totrue,otheris not evaluated.- Parameters:
other- The other checker.- Returns:
- A checker that is the logical OR composition of this checker
with
other.
-
after
Creates a checkers that checks that a value is convertible from a source type to a target type, then matches a checker of the target type.- Type Parameters:
S- The source type.- Parameters:
converter- A converter from a source type to a type that is compliant with this checker.- Returns:
- A new checker that first applies the
converter, then this checker.
-
afterRaw
-
after
Creates a checkers that checks that a value is convertible from a source type to a target type, then matches a checker of the target type.- Type Parameters:
S- The source type.- Parameters:
function- A function from a source type to a type that is compliant with this checker.sourceClass- The source class.- Returns:
- A new checker that first applies the
function, then this checker.
-
wrap
-
fromConverter
Creates a checker from a converter.The checker checks that the argument is convertible.
- Type Parameters:
S- The source type.- Parameters:
converter- The converter.- Returns:
- A checker from
converter.
-
fromFunction
static <S,T> Checker<S> fromFunction(Function<S, ?> function, Class<S> sourceClass, Class<T> targetClass) Creates a checker from a function.The checker checks that the argument is accepted (convertible) by the function.
- Type Parameters:
S- The source type.T- The target type.- Parameters:
function- The function.sourceClass- The source class.targetClass- The target class.- Returns:
- A checker from
function.
-