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 ConfigResolveOptionsappendResolver(ConfigResolver value)Returns options where the given resolver used as a fallback if a reference cannot be otherwise resolved.static ConfigResolveOptionsdefaults()Returns the default resolve options.booleangetAllowUnresolved()Returns whether the options allow unresolved substitutions.ConfigResolvergetResolver()Returns the resolver to use as a fallback if a substitution cannot be otherwise resolved.booleangetUseSystemEnvironment()Returns whether the options enable use of system environment variables.static ConfigResolveOptionsnoSystem()Returns resolve options that disable any reference to "system" data (currently, this means environment variables).ConfigResolveOptionssetAllowUnresolved(boolean value)Returns options with "allow unresolved" set to the given value.ConfigResolveOptionssetUseSystemEnvironment(boolean value)Returns options with use of environment variables set to the given value.
-
-
-
Method Detail
-
defaults
public static 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 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 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 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 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 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
-
-