Package com.typesafe.config
Class ConfigResolveOptions
- java.lang.Object
-
- com.typesafe.config.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 prebuiltnoSystem()
which avoids looking at any system environment variables or other external system information. (Right now, environment variables are the only example.)
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ConfigResolveOptions
appendResolver(ConfigResolver value)
Returns options where the given resolver used as a fallback if a reference cannot be otherwise resolved.static ConfigResolveOptions
defaults()
Returns the default resolve options.boolean
getAllowUnresolved()
Returns whether the options allow unresolved substitutions.ConfigResolver
getResolver()
Returns the resolver to use as a fallback if a substitution cannot be otherwise resolved.boolean
getUseSystemEnvironment()
Returns whether the options enable use of system environment variables.static ConfigResolveOptions
noSystem()
Returns resolve options that disable any reference to "system" data (currently, this means environment variables).ConfigResolveOptions
setAllowUnresolved(boolean value)
Returns options with "allow unresolved" set to the given value.ConfigResolveOptions
setUseSystemEnvironment(boolean value)
Returns options with use of environment variables set to the given value.
-
-
-
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, butConfig.resolve(ConfigResolveOptions)
itself will not throw.- Parameters:
value
- true to silently ignore unresolved substitutions.- Returns:
- options with requested setting for whether to allow substitutions
- Since:
- 1.2.0
-
appendResolver
public ConfigResolveOptions appendResolver(ConfigResolver value)
Returns options where the given resolver used as a fallback if a reference cannot be otherwise resolved. This resolver will only be called after resolution has failed to substitute with a value from within the config itself and with any other resolvers that have been appended before this one. Multiple resolvers can be added using,ConfigResolveOptions options = ConfigResolveOptions.defaults() .appendResolver(primary) .appendResolver(secondary) .appendResolver(tertiary);
With this config unresolved references will first be resolved with the primary resolver, if that fails then the secondary, and finally if that also fails the tertiary. If all fallbacks fail to return a substitution "allow unresolved" determines whether resolution fails or continues. `- Parameters:
value
- the resolver to fall back to- Returns:
- options that use the given resolver as a fallback
- Since:
- 1.3.2
-
getResolver
public ConfigResolver getResolver()
Returns the resolver to use as a fallback if a substitution cannot be otherwise resolved. Never returns null. This method is mostly used by the config lib internally, not by applications.- Returns:
- the non-null fallback resolver
- Since:
- 1.3.2
-
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
-
-