code: public static <K> void validateConfiguredTypes(CacheConfig cacheConfig, K key) throws ClassCastException {
          Class keyType = cacheConfig.getKeyType();
          validateConfiguredKeyType(keyType, key);
      }
docs: Validates that the configured key matches the provided key.
  
  @param cacheConfig Cache configuration.
  @param key         the key to be validated with its type.
  @param <K>         the type of key.
  @throws ClassCastException if the provided key does not match with configured type.