Top Description Fields Constructors Methods
com.typesafe.config

public final Class ConfigResolveOptions

extends Object
Class Inheritance

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 ConfigResolveOptions#defaults, there's a prebuilt ConfigResolveOptions#noSystem which avoids looking at any system environment variables or other external system information. (Right now, environment variables are the only example.)

Field Summary

Modifier and TypeField and Description
private final boolean
private static final ConfigResolver
NULL_RESOLVER

Singleton resolver that never resolves paths.

private final ConfigResolver
private final boolean

Constructor Summary

AccessConstructor and Description
private
ConfigResolveOptions(boolean useSystemEnvironment, boolean allowUnresolved, ConfigResolver resolver)

Method Summary

Modifier and TypeMethod and Description
public ConfigResolveOptions

Returns:

options that use the given resolver as a fallback
appendResolver
(ConfigResolver
the resolver to fall back to
value
)

Returns options where the given resolver used as a fallback if a reference cannot be otherwise resolved.

public static ConfigResolveOptions

Returns:

the default resolve options
defaults
()

Returns the default resolve options.

public boolean

Returns:

true if unresolved substitutions are allowed
getAllowUnresolved
()

Returns whether the options allow unresolved substitutions.

public ConfigResolver

Returns:

the non-null fallback resolver
getResolver
()

Returns the resolver to use as a fallback if a substitution cannot be otherwise resolved.

public boolean

Returns:

true if environment variables should be used
getUseSystemEnvironment
()

Returns whether the options enable use of system environment variables.

public static ConfigResolveOptions

Returns:

the resolve options with env variables disabled
noSystem
()

Returns resolve options that disable any reference to "system" data (currently, this means environment variables).

public ConfigResolveOptions

Returns:

options with requested setting for whether to allow substitutions
setAllowUnresolved
(boolean
true to silently ignore unresolved substitutions.
value
)

Returns options with "allow unresolved" set to the given value.

public ConfigResolveOptions

Returns:

options with requested setting for use of environment variables
setUseSystemEnvironment
(boolean
true to resolve substitutions falling back to environment variables.
value
)

Returns options with use of environment variables set to the given value.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allowUnresolvedback to summary
private final boolean allowUnresolved
NULL_RESOLVERback to summary
private static final ConfigResolver NULL_RESOLVER

Singleton resolver that never resolves paths.

resolverback to summary
private final ConfigResolver resolver
useSystemEnvironmentback to summary
private final boolean useSystemEnvironment

Constructor Detail

ConfigResolveOptionsback to summary
private ConfigResolveOptions(boolean useSystemEnvironment, boolean allowUnresolved, ConfigResolver resolver)

Method Detail

appendResolverback to summary
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:ConfigResolver

the resolver to fall back to

Returns:ConfigResolveOptions

options that use the given resolver as a fallback

Since
1.3.2
defaultsback to summary
public static ConfigResolveOptions defaults()

Returns the default resolve options. By default the system environment will be used and unresolved substitutions are not allowed.

Returns:ConfigResolveOptions

the default resolve options

getAllowUnresolvedback to summary
public boolean getAllowUnresolved()

Returns whether the options allow unresolved substitutions. This method is mostly used by the config lib internally, not by applications.

Returns:boolean

true if unresolved substitutions are allowed

Since
1.2.0
getResolverback to summary
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:ConfigResolver

the non-null fallback resolver

Since
1.3.2
getUseSystemEnvironmentback to summary
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:boolean

true if environment variables should be used

noSystemback to summary
public static ConfigResolveOptions noSystem()

Returns resolve options that disable any reference to "system" data (currently, this means environment variables).

Returns:ConfigResolveOptions

the resolve options with env variables disabled

setAllowUnresolvedback to summary
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 not throw.

Parameters
value:boolean

true to silently ignore unresolved substitutions.

Returns:ConfigResolveOptions

options with requested setting for whether to allow substitutions

Since
1.2.0
setUseSystemEnvironmentback to summary
public ConfigResolveOptions setUseSystemEnvironment(boolean value)

Returns options with use of environment variables set to the given value.

Parameters
value:boolean

true to resolve substitutions falling back to environment variables.

Returns:ConfigResolveOptions

options with requested setting for use of environment variables