Class ConfigRetriever

java.lang.Object
com.github.rlacher.sortbench.config.ConfigRetriever

public final class ConfigRetriever extends Object
Utility class for validating and retrieving configuration values from a map.

Expands on standard CLI argument validation with context-specific configuration checks.

  • Method Details

    • validateAndFilterMap

      public static <T> Map<String,T> validateAndFilterMap(Map<String,T> config, Set<String> keys, boolean throwIfNotFound)
      Validates and retrieves configuration values from a map based on a set of keys.

      This method ignores the case and leading/trailing whitespaces of the keys.

      If a key is not found, it will be ignored unless throwIfNotFound is true.

      Type Parameters:
      T - The type of the configuration values.
      Parameters:
      config - The map containing the configuration.
      keys - A set of keys to look for in the configuration map (case-insensitive).
      throwIfNotFound - If true, an exception is thrown if a key in keys is not found in the config.
      Returns:
      A map of the found configuration values.
      Throws:
      IllegalArgumentException - If config is null, keys is null, any key in keys is null or blank, or if a key in keys is not found in the config and throwIfNotFound is true.