Class KiwiCasts2.StandardMapCheckStrategy

java.lang.Object
org.kiwiproject.beta.base.KiwiCasts2.StandardMapCheckStrategy
All Implemented Interfaces:
KiwiCasts2.MapCheckStrategy
Enclosing class:
KiwiCasts2

public static class KiwiCasts2.StandardMapCheckStrategy extends Object implements KiwiCasts2.MapCheckStrategy
Standard implementation of KiwiCasts2.MapCheckStrategy that allows configuring the number of non-null and type checks to perform.
  • Method Details

    • ofDefaults

      public static KiwiCasts2.StandardMapCheckStrategy ofDefaults()
      Creates a new instance with default settings for maximum non-null and type checks.

      Uses KiwiCasts2.DEFAULT_MAX_NON_NULL_CHECKS and KiwiCasts2.DEFAULT_MAX_TYPE_CHECKS as the values for maxNonNullChecks and maxElementTypeChecks, respectively.

      Returns:
      a new instance
    • of

      public static KiwiCasts2.StandardMapCheckStrategy of(int maxNonNullChecks, int maxElementTypeChecks)
      Creates a new instance with the specified maximum non-null and type checks.
      Parameters:
      maxNonNullChecks - the maximum number of non-null checks to perform
      maxElementTypeChecks - the maximum number of entry type checks to perform
      Returns:
      a new instance with the specified settings
    • checkEntries

      public <K, V> Map<K,V> checkEntries(Class<K> keyType, Class<V> valueType, Map<K,V> map)
      Checks that keys and values in the map are of the expected types.
      Specified by:
      checkEntries in interface KiwiCasts2.MapCheckStrategy
      Type Parameters:
      K - the expected key type
      V - the expected value type
      Parameters:
      keyType - the expected type of keys in the map
      valueType - the expected type of values in the map
      map - the map to check
      Returns:
      the original map if all keys and values match the expected types