Class MpConfig

  • All Implemented Interfaces:
    Config

    public final class MpConfig
    extends Object
    implements Config
    Microprofile config wrapper of Config.
    • Method Detail

      • builder

        public static MpConfigBuilder builder()
        Get a builder for config instances.
        Returns:
        a new builder
      • getValue

        public <T> T getValue​(String propertyName,
                              Class<T> propertyType)
        Specified by:
        getValue in interface Config
      • asSet

        public <T> Set<T> asSet​(String propertyName,
                                Class<T> typeArg)
        Return value as a Set of values.
        Type Parameters:
        T - type of elements
        Parameters:
        propertyName - name of property
        typeArg - type of elements in the set
        Returns:
        set with elements found in properties
      • asList

        public <T> List<T> asList​(String propertyName,
                                  Class<T> typeArg)
        Return value as a List of values.
        Type Parameters:
        T - type of elements
        Parameters:
        propertyName - name of property
        typeArg - type of elements in the list
        Returns:
        list with elements found in properties
      • value

        public <T> T value​(String propertyName,
                           Class<T> propertyType,
                           T defaultValue)
        Get value with a default if it does not exist.
        Type Parameters:
        T - type of the property
        Parameters:
        propertyName - name of the property
        propertyType - type of the property
        defaultValue - default value correctly typed
        Returns:
        value from configuration or default value if not available
      • valueWithDefault

        public <T> T valueWithDefault​(String propertyName,
                                      Class<T> propertyType,
                                      String defaultValue)
        Get value with a default if it does not exist.
        Type Parameters:
        T - type of the property
        Parameters:
        propertyName - name of the property
        propertyType - type of the property
        defaultValue - default value as String
        Returns:
        value from configuration or default value coerced to correct type if not available
      • convert

        public <T> T convert​(Class<T> type,
                             String value)
        Try to coerce the value to the specific type.
        Type Parameters:
        T - type we expect (e.g. String, Integer or a java bean)
        Parameters:
        type - type to return
        value - string value to parse
        Returns:
        null if value is null, transformed object otherwise
        Throws:
        IllegalArgumentException - if the value cannot be converted to the specified type using.
      • helidonConfig

        public Config helidonConfig()
        Get an instance of Helidon config (a tree structure) rather than the microprofile config.
        Returns:
        config instance that has the same properties as this instance
      • asMap

        public Map<String,​String> asMap()
        Get all properties of this config as a map.
        Returns:
        map where keys are configuration keys and values are associated string values