Interface ConfigMapper


  • public interface ConfigMapper
    Config mapper is provided to ConfigMapperProvider to help transformation of complex structures.
    • Method Detail

      • map

        <T> T map​(Config config,
                  GenericType<T> type)
           throws MissingValueException,
                  ConfigMappingException
        Convert the specified Config node into the target type specified by GenericType. You can use GenericType.create(Type) if needed to wrap a parametrized type.
        Type Parameters:
        T - type of the result
        Parameters:
        config - config node to convert
        type - type to extract generics types from (to prevent type erasure)
        Returns:
        converted value, never null
        Throws:
        MissingValueException - in case a value is expected and not found (either on this config node or on a subnode)
        ConfigMappingException - in case the config node cannot be converted into the expected type (e.g. value is "hello" and expected type is List<Integer>)
      • map

        <T> T map​(Config config,
                  Class<T> type)
           throws MissingValueException,
                  ConfigMappingException
        Converts the specified Config node to the target type.

        The method uses the mapper function instance associated with the specified type to convert the Config subtree. If there is none it tries to find one from ConfigMapperProvider.mapper(Class) from configured mapper providers. If none is found, mapping will throw a ConfigMappingException.

        Type Parameters:
        T - type to which the config node is to be transformed
        Parameters:
        config - config node to be transformed
        type - type to which the config node is to be transformed
        Returns:
        transformed value of type T; never returns null
        Throws:
        MissingValueException - in case the configuration node does not represent an existing configuration node
        ConfigMappingException - in case the mapper fails to map the existing configuration value to an instance of a given Java type
      • map

        <T> T map​(String value,
                  Class<T> type,
                  String key)
           throws MissingValueException,
                  ConfigMappingException
        Converts the value to the target type.
        Type Parameters:
        T - type of the converted value
        Parameters:
        value - String value to convert
        type - type to convert to
        key - configuration key to be used to create appropriate exceptions
        Returns:
        value converted to the correct type
        Throws:
        MissingValueException - iin case a value is expected and not found (e.g. when trying to convert to a complex object)
        ConfigMappingException - in case the String cannot be converted to the expected type
      • map

        <T> T map​(String value,
                  GenericType<T> type,
                  String key)
           throws MissingValueException,
                  ConfigMappingException
        Converts the value to the target generic type.
        Type Parameters:
        T - type of the converted value
        Parameters:
        value - String value to convert
        type - generic type to convert to
        key - configuration key to be used to create appropriate exceptions
        Returns:
        value converted to the correct type
        Throws:
        MissingValueException - iin case a value is expected and not found (e.g. when trying to convert to a complex object)
        ConfigMappingException - in case the String cannot be converted to the expected type