Class CheckerArray<T>
java.lang.Object
util.AbstractChecker<T[],CheckerArray<T>>
specialized_checkers.math.CheckerArray<T>
- Type Parameters:
T
- the type of the elements in the array being checked
- All Implemented Interfaces:
InterfaceChecker<AbstractChecker<T[],
CheckerArray<T>>, T[]>
Checker for array instances, providing fluent validation methods for arrays of any reference type.
This class allows you to validate and assert properties of array objects in a fluent and readable way.
-
Field Summary
Fields inherited from class util.AbstractChecker
backObject, exceptionTracker, name, object, saveErrors, stop
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CheckerArray
(T[] array, String name) Constructs a newCheckerArray
with the specified array and name. -
Method Summary
Modifier and TypeMethodDescriptionAsserts that all elements in the array match the provided predicate.Asserts that any element in the array matches the provided predicate.static <T> CheckerArray
<T> check
(T[] array) Creates a newCheckerArray
for the given array instance with a default name.static <T> CheckerArray
<T> Creates a newCheckerArray
for the given array instance with a custom name.isEmpty()
Asserts that the array is empty (has zero length).Asserts that the array is sorted in ascending order according to the natural ordering of its elements.isSortedAsc
(Comparator<T> comparator) Asserts that the array is sorted in ascending order according to the provided comparator.Asserts that the array is sorted in descending order according to the natural ordering of its elements.isSortedDesc
(Comparator<T> comparator) Asserts that the array is sorted in descending order according to the provided comparator.isSufficientPercentage
(Predicate<T> matching, double percentage) Asserts that at least the given percentage of elements in the array match the provided predicate.protected CheckerArray
<T> self()
Returns this checker instance (for fluent API usage).Methods inherited from class util.AbstractChecker
checkProperty, checkProperty, checkProperty, end, getMethod, getObject, getProperty, hasErrors, hasNotErrors, is, is, isEqual, isNonNull, isNot, isNot, isNull, notSaveErrors, saveErrors, show, showNotThrownException, showThrownException, stop
-
Constructor Details
-
CheckerArray
-
-
Method Details
-
check
Creates a newCheckerArray
for the given array instance with a custom name.- Type Parameters:
T
- the type of the elements in the array- Parameters:
array
- the array instance to be checkedname
- the name to identify this checker instance (useful for error messages)- Returns:
- a new
CheckerArray
for the provided array
-
check
Creates a newCheckerArray
for the given array instance with a default name.- Type Parameters:
T
- the type of the elements in the array- Parameters:
array
- the array instance to be checked- Returns:
- a new
CheckerArray
for the provided array
-
self
Returns this checker instance (for fluent API usage).- Specified by:
self
in classAbstractChecker<T[],
CheckerArray<T>> - Returns:
- this
CheckerArray
instance
-
isEmpty
Asserts that the array is empty (has zero length).- Returns:
- this
CheckerArray
instance for further validation
-
isSortedAsc
Asserts that the array is sorted in ascending order according to the provided comparator.- Parameters:
comparator
- the comparator to determine the order of the array- Returns:
- this
CheckerArray
instance for further validation
-
isSortedAsc
Asserts that the array is sorted in ascending order according to the natural ordering of its elements.- Returns:
- this
CheckerArray
instance for further validation
-
isSortedDesc
Asserts that the array is sorted in descending order according to the provided comparator.- Parameters:
comparator
- the comparator to determine the order of the array- Returns:
- this
CheckerArray
instance for further validation
-
isSortedDesc
Asserts that the array is sorted in descending order according to the natural ordering of its elements.- Returns:
- this
CheckerArray
instance for further validation
-
isSufficientPercentage
Asserts that at least the given percentage of elements in the array match the provided predicate.- Parameters:
matching
- the predicate to test elementspercentage
- the minimum percentage of elements that must match- Returns:
- this
CheckerArray
instance for further validation
-
anyMatch
Asserts that any element in the array matches the provided predicate.- Parameters:
predicate
- the predicate to test elements- Returns:
- this
CheckerArray
instance for further validation
-
allMatch
Asserts that all elements in the array match the provided predicate.- Parameters:
predicate
- the predicate to test elements- Returns:
- this
CheckerArray
instance for further validation
-