Class CheckerMap<K,V>

java.lang.Object
util.AbstractChecker<Map<K,V>,CheckerMap<K,V>>
specialized_checkers.collection.CheckerMap<K,V>
Type Parameters:
K - the type of keys maintained by the map
V - the type of mapped values
All Implemented Interfaces:
InterfaceChecker<AbstractChecker<Map<K,V>,CheckerMap<K,V>>,Map<K,V>>

public class CheckerMap<K,V> extends AbstractChecker<Map<K,V>,CheckerMap<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:
  • Constructor Details

    • CheckerMap

      protected CheckerMap(Map<K,V> map, String name)
      Constructs a new CheckerMap with the specified backing map and name.
      Parameters:
      map - the backing map to be used by this CheckerMap
      name - the name associated with this CheckerMap
  • Method Details

    • check

      public static <K, V> CheckerMap<K,V> check(Map<K,V> map, String name)
      Creates a CheckerMap for the given map and assigns a custom name.
      Type Parameters:
      K - the Map's key type
      V - the Map's value type
      Parameters:
      map - the map to check
      name - the name to assign to this checker
      Returns:
      a CheckerMap instance for the given map
    • check

      public static <K, V> CheckerMap<K,V> check(Map<K,V> map)
      Creates a CheckerMap for the given map with a default name.
      Type Parameters:
      K - the Map's key type
      V - the Map's value type
      Parameters:
      map - the map to check
      Returns:
      a CheckerMap instance for the given map
    • self

      protected CheckerMap<K,V> self()
      Returns this instance (for fluent API).
      Specified by:
      self in class AbstractChecker<Map<K,V>,CheckerMap<K,V>>
      Returns:
      this CheckerMap instance
    • isEmpty

      public CheckerMap<K,V> isEmpty()
      Checks if the map is empty.
      Returns:
      this CheckerMap instance
    • anyMatch

      public CheckerMap<K,V> anyMatch(Predicate<Map.Entry<K,V>> predicate)
      Checks if any entry in the map matches the given predicate.
      Parameters:
      predicate - the condition to test map entries
      Returns:
      this CheckerMap instance
    • anyMatch

      public CheckerMap<K,V> anyMatch(BiPredicate<K,V> predicate)
      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

      public CheckerMap<K,V> allMatch(Predicate<Map.Entry<K,V>> predicate)
      Checks if all entries in the map match the given predicate.
      Parameters:
      predicate - the condition to test map entries
      Returns:
      this CheckerMap instance
    • allMatch

      public CheckerMap<K,V> allMatch(BiPredicate<K,V> predicate)
      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