code: public static <K, V> void validateConfiguredTypes(CacheConfig cacheConfig, K key, V value) throws ClassCastException {
          Class keyType = cacheConfig.getKeyType();
          Class valueType = cacheConfig.getValueType();
          validateConfiguredKeyType(keyType, key);
          validateConfiguredValueType(valueType, value);
      }
docs: Validates the configured key and value types matches the provided key, value types.
  
  @param cacheConfig Cache configuration.
  @param key         the key to be validated.
  @param <K>         the type of key.
  @param value       the value to be validated.
  @param <V>         the type of value.
  @throws ClassCastException if the provided key or value do not match with configured types.