Class CheckerMap<K,V>
- Type Parameters:
K
- the type of keys maintained by the mapV
- the type of mapped values
- All Implemented Interfaces:
InterfaceChecker<AbstractChecker<Map<K,
V>, CheckerMap<K, V>>, Map<K, V>>
A specialized checker for
Map
instances, providing fluent assertion methods
for validating map properties and contents.
This class extends AbstractChecker
and allows for expressive, chainable
checks on Map
objects, such as verifying emptiness, matching entries
against predicates, and more.
- See Also:
-
Field Summary
Fields inherited from class util.AbstractChecker
backObject, exceptionTracker, name, object, saveErrors, stop
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CheckerMap
(Map<K, V> map, String name) Constructs a newCheckerMap
with the specified backing map and name. -
Method Summary
Modifier and TypeMethodDescriptionCheckerMap
<K, V> allMatch
(BiPredicate<K, V> predicate) Checks if all entries in the map match the given bi-predicate.CheckerMap
<K, V> Checks if all entries in the map match the given predicate.CheckerMap
<K, V> anyMatch
(BiPredicate<K, V> predicate) Checks if any entry in the map matches the given bi-predicate.CheckerMap
<K, V> Checks if any entry in the map matches the given predicate.static <K,
V> CheckerMap <K, V> Creates a CheckerMap for the given map with a default name.static <K,
V> CheckerMap <K, V> Creates a CheckerMap for the given map and assigns a custom name.CheckerMap
<K, V> isEmpty()
Checks if the map is empty.protected CheckerMap
<K, V> self()
Returns this instance (for fluent API).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
-
CheckerMap
-
-
Method Details
-
check
Creates a CheckerMap for the given map and assigns a custom name.- Type Parameters:
K
- theMap
's key typeV
- theMap
's value type- Parameters:
map
- the map to checkname
- the name to assign to this checker- Returns:
- a CheckerMap instance for the given map
-
check
Creates a CheckerMap for the given map with a default name.- Type Parameters:
K
- theMap
's key typeV
- theMap
's value type- Parameters:
map
- the map to check- Returns:
- a CheckerMap instance for the given map
-
self
Returns this instance (for fluent API).- Specified by:
self
in classAbstractChecker<Map<K,
V>, CheckerMap<K, V>> - Returns:
- this CheckerMap instance
-
isEmpty
-
anyMatch
-
anyMatch
Checks if any entry in the map matches the given bi-predicate.- Parameters:
predicate
- the condition to test key-value pairs- Returns:
- this CheckerMap instance
-
allMatch
-
allMatch
Checks if all entries in the map match the given bi-predicate.- Parameters:
predicate
- the condition to test key-value pairs- Returns:
- this CheckerMap instance
-