Interface StructuredConfigProperties

    • Method Detail

      • empty

        static StructuredConfigProperties empty()
        Return an empty StructuredConfigProperties instance.

        Useful for walking the tree without checking for null. For example, to access a string key nested at .foo.bar.baz, call: config.getStructured("foo", empty()).getStructured("bar", empty()).getString("baz").

      • getString

        @Nullable
        java.lang.String getString​(java.lang.String name)
        Returns a String configuration property.
        Returns:
        null if the property has not been configured
        Throws:
        ConfigurationException - if the property is not a valid scalar string
      • getString

        default java.lang.String getString​(java.lang.String name,
                                           java.lang.String defaultValue)
        Returns a String configuration property.
        Returns:
        a String configuration property or defaultValue if a property with name has not been configured
        Throws:
        ConfigurationException - if the property is not a valid scalar string
      • getBoolean

        @Nullable
        java.lang.Boolean getBoolean​(java.lang.String name)
        Returns a Boolean configuration property. Implementations should use the same rules as Boolean.parseBoolean(String) for handling the values.
        Returns:
        null if the property has not been configured
        Throws:
        ConfigurationException - if the property is not a valid scalar boolean
      • getBoolean

        default boolean getBoolean​(java.lang.String name,
                                   boolean defaultValue)
        Returns a Boolean configuration property.
        Returns:
        a Boolean configuration property or defaultValue if a property with name has not been configured
        Throws:
        ConfigurationException - if the property is not a valid scalar boolean
      • getInt

        @Nullable
        java.lang.Integer getInt​(java.lang.String name)
        Returns a Integer configuration property.

        If the underlying config property is Long, it is converted to Integer with Long.intValue() which may result in loss of precision.

        Returns:
        null if the property has not been configured
        Throws:
        ConfigurationException - if the property is not a valid scalar integer
      • getInt

        default int getInt​(java.lang.String name,
                           int defaultValue)
        Returns a Integer configuration property.

        If the underlying config property is Long, it is converted to Integer with Long.intValue() which may result in loss of precision.

        Returns:
        a Integer configuration property or defaultValue if a property with name has not been configured
        Throws:
        ConfigurationException - if the property is not a valid scalar integer
      • getLong

        @Nullable
        java.lang.Long getLong​(java.lang.String name)
        Returns a Long configuration property.
        Returns:
        null if the property has not been configured
        Throws:
        ConfigurationException - if the property is not a valid scalar long
      • getLong

        default long getLong​(java.lang.String name,
                             long defaultValue)
        Returns a Long configuration property.
        Returns:
        a Long configuration property or defaultValue if a property with name has not been configured
        Throws:
        ConfigurationException - if the property is not a valid scalar long
      • getDouble

        @Nullable
        java.lang.Double getDouble​(java.lang.String name)
        Returns a Double configuration property.
        Returns:
        null if the property has not been configured
        Throws:
        ConfigurationException - if the property is not a valid scalar double
      • getDouble

        default double getDouble​(java.lang.String name,
                                 double defaultValue)
        Returns a Double configuration property.
        Returns:
        a Double configuration property or defaultValue if a property with name has not been configured
        Throws:
        ConfigurationException - if the property is not a valid scalar double
      • getScalarList

        @Nullable
        <T> java.util.List<T> getScalarList​(java.lang.String name,
                                            java.lang.Class<T> scalarType)
        Returns a List configuration property. Empty values and values which do not map to the scalarType will be removed.
        Parameters:
        name - the property name
        scalarType - the scalar type, one of String, Boolean, Long or Double
        Returns:
        a List configuration property, or null if the property has not been configured
        Throws:
        ConfigurationException - if the property is not a valid sequence of scalars, or if scalarType is not supported
      • getScalarList

        default <T> java.util.List<T> getScalarList​(java.lang.String name,
                                                    java.lang.Class<T> scalarType,
                                                    java.util.List<T> defaultValue)
        Returns a List configuration property. Entries which are not strings are converted to their string representation.
        Returns:
        a List configuration property or defaultValue if a property with name has not been configured
        Throws:
        ConfigurationException - if the property is not a valid sequence of scalars
        See Also:
        ConfigProperties.getList(String name)
      • getPropertyKeys

        java.util.Set<java.lang.String> getPropertyKeys()
        Returns a set of all configuration property keys.
        Returns:
        the configuration property keys