Class ConfigResolveOptions


  • public final class ConfigResolveOptions
    extends java.lang.Object
    A set of options related to resolving substitutions. Substitutions use the ${foo.bar} syntax and are documented in the HOCON spec.

    Typically this class would be used with the method Config.resolve(ConfigResolveOptions).

    This object is immutable, so the "setters" return a new object.

    Here is an example of creating a custom ConfigResolveOptions:

         ConfigResolveOptions options = ConfigResolveOptions.defaults()
             .setUseSystemEnvironment(false)
     

    In addition to defaults(), there's a prebuilt noSystem() which avoids looking at any system environment variables or other external system information. (Right now, environment variables are the only example.)

    • Method Detail

      • defaults

        public static ConfigResolveOptions defaults()
        Returns the default resolve options. By default the system environment will be used and unresolved substitutions are not allowed.
        Returns:
        the default resolve options
      • noSystem

        public static ConfigResolveOptions noSystem()
        Returns resolve options that disable any reference to "system" data (currently, this means environment variables).
        Returns:
        the resolve options with env variables disabled
      • setUseSystemEnvironment

        public ConfigResolveOptions setUseSystemEnvironment​(boolean value)
        Returns options with use of environment variables set to the given value.
        Parameters:
        value - true to resolve substitutions falling back to environment variables.
        Returns:
        options with requested setting for use of environment variables
      • getUseSystemEnvironment

        public boolean getUseSystemEnvironment()
        Returns whether the options enable use of system environment variables. This method is mostly used by the config lib internally, not by applications.
        Returns:
        true if environment variables should be used
      • setAllowUnresolved

        public ConfigResolveOptions setAllowUnresolved​(boolean value)
        Returns options with "allow unresolved" set to the given value. By default, unresolved substitutions are an error. If unresolved substitutions are allowed, then a future attempt to use the unresolved value may fail, but Config.resolve(ConfigResolveOptions) itself will now throw.
        Parameters:
        value - true to silently ignore unresolved substitutions.
        Returns:
        options with requested setting for whether to allow substitutions
        Since:
        1.2.0
      • getAllowUnresolved

        public boolean getAllowUnresolved()
        Returns whether the options allow unresolved substitutions. This method is mostly used by the config lib internally, not by applications.
        Returns:
        true if unresolved substitutions are allowed
        Since:
        1.2.0