ConfigurationHelper (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.util, class: ConfigurationHelper

Package org.apache.hadoop.util

# Class ConfigurationHelper

java.lang.Object
org.apache.hadoop.util.ConfigurationHelper

@Private public final class ConfigurationHelper extends Object
Configuration Helper class to provide advanced configuration parsing. Private; external code MUST use `Configuration` instead

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static <E extends Enum<E>>
  Map<String,E>`
  `mapEnumNamesToValues(String prefix, Class<E> enumClass)`
  Given an enum class, build a map of lower case names to values.
  `static <E extends Enum<E>>
  EnumSet<E>`
  `parseEnumSet(String key, String valueString, Class<E> enumClass, boolean ignoreUnknown)`
  Given a comma separated list of enum values, trim the list, map to enum values in the message (case insensitive) and return the set.
  `static <E extends Enum<E>>
  E`
  `resolveEnum(Configuration conf, String name, Class<E> enumClass, Function<String,E> fallback)`
  Look up an enum from the configuration option and map it to a value in the supplied enum class.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### parseEnumSet

    public static <E extends Enum<E>> EnumSet<E> parseEnumSet(String key, String valueString, Class<E> enumClass, boolean ignoreUnknown) throws IllegalArgumentException
    Given a comma separated list of enum values, trim the list, map to enum values in the message (case insensitive) and return the set. Special handling of "*" meaning: all values.
    Type Parameters:
      `E` - enum type
    Parameters:
      `key` - Configuration object key -used in error messages.
      `valueString` - value from Configuration
      `enumClass` - class of enum
      `ignoreUnknown` - should unknown values be ignored?
    Returns:
      a mutable set of enum values parsed from the valueString, with any unknown matches stripped if `ignoreUnknown` is true.
    Throws:
      `IllegalArgumentException` - if one of the entries was unknown and ignoreUnknown is false, or there are two entries in the enum which differ only by case.

  - ### mapEnumNamesToValues

    public static <E extends Enum<E>> Map<String,E> mapEnumNamesToValues(String prefix, Class<E> enumClass)
    Given an enum class, build a map of lower case names to values.
    Type Parameters:
      `E` - enum type
    Parameters:
      `prefix` - prefix (with trailing ".") for path capabilities probe
      `enumClass` - class of enum
    Returns:
      a mutable map of lower case names to enum values
    Throws:
      `IllegalArgumentException` - if there are two entries which differ only by case.

  - ### resolveEnum

    public static <E extends Enum<E>> E resolveEnum(Configuration conf, String name, Class<E> enumClass, Function<String,E> fallback)
    Look up an enum from the configuration option and map it to a value in the supplied enum class. If no value is supplied or there is no match for the supplied value, the fallback function is invoked, passing in the trimmed and possibly empty string of the value. Extends {link `Configuration.getEnum(String, Enum)`} by adding case independence and a lambda expression for fallback, rather than a default value.
    Type Parameters:
      `E` - enumeration type.
    Parameters:
      `conf` - configuration
      `name` - property name
      `enumClass` - classname to resolve
      `fallback` - fallback supplier
    Returns:
      an enum value
    Throws:
      `IllegalArgumentException` - If mapping is illegal for the type provided