class Example {
public static void main(String... args) {
assert all(
objectValue(arg[0]).isNotNull().$(),
objectValue(new Example()).isNotNull().$(),
...
);
}
}
V
- The type of the checker.T
- The type from which the target value is transformed.R
- The type of the target value.public interface Checker<V extends Checker<V,T,R>,T,R> extends Matcher<V,T,R>, Statement<T>
An interface that defines methods to check a target value.
By default, calls of checking methods defined in this and sub-interfaces of this interface will be a conjunction of them.
To make it a disjunction, call Matcher.anyOf()
.
User-exposing methods to check values in this method names should be progressive and its objective so that they can follow "to be" or "satisfies" in an English sentence.
Modifier and Type | Interface and Description |
---|---|
static class |
Checker.Base<V extends Checker<V,T,R>,T,R> |
Matcher.JunctionType
Modifier and Type | Method and Description |
---|---|
default Statement<Object> |
$()
When you use an assertion method that accepts multiple statements (
Statement ), it requires all the elements in the array (varargs ) should have the same generic parameter type. |
V |
addCheckPhrase(Function<Checker<?,R,R>,Predicate<R>> phrase) |
default V |
checkWithPredicate(Predicate<? super R> predicate)
Checks if the target value satisfies the given
predicate . |
default Predicate<T> |
done()
Convert this object into a printable predicate to check the target value.
|
default V |
not(Function<V,V> phrase) |
default V |
predicate(Predicate<? super R> predicate)
A synonym of
checkWithPredicate(Predicate) . |
allOf, anyOf, toPredicate, transformFunction
booleanValue, createPredicateForAllOf, doubleValue, floatValue, integerValue, listValue, longValue, objectValue, shortValue, statementPredicate, statementValue, streamValue, stringValue, throwableValue
default V checkWithPredicate(Predicate<? super R> predicate)
Checks if the target value satisfies the given predicate
.
predicate
- A predicate to check the target value.default V predicate(Predicate<? super R> predicate)
A synonym of checkWithPredicate(Predicate)
.
predicate
- A predicate to check the target value.default Predicate<T> done()
Convert this object into a printable predicate to check the target value.
default Statement<Object> $()
When you use an assertion method that accepts multiple statements (Statement
), it requires all the elements in the array (varargs
) should have the same generic parameter type.
However, you sometimes want to check multiple types at once.
By calling this method for every statement building method calling chain, you can address the compilation error.
class Example {
public static void main(String... args) {
assert all(
objectValue(arg[0]).isNotNull().$(),
objectValue(new Example()).isNotNull().$(),
...
);
}
}
java.lang.Object
type.Copyright © 2024. All rights reserved.