public interface Config extends ConfigMergeable
foo.bar.baz
. Values are as in JSON
(booleans, strings, numbers, lists, or objects), represented by
ConfigValue
instances. Values accessed through the
Config
interface are never null.
Config
is an immutable object and thus safe to use from multiple
threads. There's never a need for "defensive copies."
Fundamental operations on a Config
include getting configuration
values, resolving substitutions with resolve()
, and
merging configs using withFallback(ConfigMergeable)
.
All operations return a new immutable Config
rather than modifying
the original instance.
Examples
You can find an example app and library on GitHub. Also be sure to read the package overview which describes the big picture as shown in those examples.
Paths, keys, and Config vs. ConfigObject
Config
is a view onto a tree of ConfigObject
; the
corresponding object tree can be found through root()
.
ConfigObject
is a map from config keys, rather than
paths, to config values. Think of ConfigObject
as a JSON object
and Config
as a configuration API.
The API tries to consistently use the terms "key" and "path." A key is a key in a JSON object; it's just a string that's the key in a map. A "path" is a parseable expression with a syntax and it refers to a series of keys. Path expressions are described in the spec for Human-Optimized Config Object Notation. In brief, a path is period-separated so "a.b.c" looks for key c in object b in object a in the root object. Sometimes double quotes are needed around special characters in path expressions.
The API for a Config
is in terms of path expressions, while the API
for a ConfigObject
is in terms of keys. Conceptually, Config
is a one-level map from paths to values, while a
ConfigObject
is a tree of nested maps from keys to values.
Use ConfigUtil.joinPath(java.lang.String...)
and ConfigUtil.splitPath(java.lang.String)
to convert
between path expressions and individual path elements (keys).
Another difference between Config
and ConfigObject
is that
conceptually, ConfigValue
s with a valueType()
of NULL
exist in a
ConfigObject
, while a Config
treats null values as if they
were missing. (With the exception of two methods: hasPathOrNull(java.lang.String)
and getIsNull(java.lang.String)
let you detect null
values.)
Getting configuration values
The "getters" on a Config
all work in the same way. They never return
null, nor do they return a ConfigValue
with
valueType()
of NULL
. Instead, they throw ConfigException.Missing
if the value is
completely absent or set to null. If the value is set to null, a subtype of
ConfigException.Missing
called ConfigException.Null
will be
thrown. ConfigException.WrongType
will be thrown anytime you ask for
a type and the value has an incompatible type. Reasonable type conversions
are performed for you though.
Iteration
If you want to iterate over the contents of a Config
, you can get its
ConfigObject
with root()
, and then iterate over the
ConfigObject
(which implements java.util.Map
). Or, you
can use entrySet()
which recurses the object tree for you and builds
up a Set
of all path-value pairs where the value is not null.
Resolving substitutions
Substitutions are the ${foo.bar}
syntax in config
files, described in the specification. Resolving substitutions replaces these references with real
values.
Before using a Config
it's necessary to call resolve()
to handle substitutions (though ConfigFactory.load()
and similar
methods will do the resolve for you already).
Merging
The full Config
for your application can be constructed using
the associative operation withFallback(ConfigMergeable)
. If
you use ConfigFactory.load()
(recommended), it merges system
properties over the top of application.conf
over the top of
reference.conf
, using withFallback
. You can add in
additional sources of configuration in the same way (usually, custom layers
should go either just above or just below application.conf
,
keeping reference.conf
at the bottom and system properties at
the top).
Serialization
Convert a Config
to a JSON or HOCON string by calling
ConfigValue.render()
on the root object,
myConfig.root().render()
. There's also a variant
ConfigValue.render(ConfigRenderOptions)
which allows you to control
the format of the rendered string. (See ConfigRenderOptions
.) Note
that Config
does not remember the formatting of the original
file, so if you load, modify, and re-save a config file, it will be
substantially reformatted.
As an alternative to ConfigValue.render()
, the
toString()
method produces a debug-output-oriented
representation (which is not valid JSON).
Java serialization is supported as well for Config
and all
subtypes of ConfigValue
.
This is an interface but don't implement it yourself
Do not implement Config
; it should only be implemented by
the config library. Arbitrary implementations will not work because the
library internals assume a specific concrete implementation. Also, this
interface is likely to grow new methods over time, so third-party
implementations will break.
Modifier and Type | Method and Description |
---|---|
Config |
atKey(java.lang.String key)
Places the config inside a
Config at the given key. |
Config |
atPath(java.lang.String path)
Places the config inside another
Config at the given path. |
void |
checkValid(Config reference,
java.lang.String... restrictToPaths)
Validates this config against a reference config, throwing an exception
if it is invalid.
|
java.util.Set<java.util.Map.Entry<java.lang.String,ConfigValue>> |
entrySet()
Returns the set of path-value pairs, excluding any null values, found by
recursing
the root object . |
java.lang.Object |
getAnyRef(java.lang.String path)
Gets the value at the path as an unwrapped Java boxed value (
Boolean , Integer , and
so on - see ConfigValue.unwrapped() ). |
java.util.List<? extends java.lang.Object> |
getAnyRefList(java.lang.String path)
Gets a list value with any kind of elements.
|
boolean |
getBoolean(java.lang.String path) |
java.util.List<java.lang.Boolean> |
getBooleanList(java.lang.String path)
Gets a list value with boolean elements.
|
java.lang.Long |
getBytes(java.lang.String path)
Gets a value as a size in bytes (parses special strings like "128M").
|
java.util.List<java.lang.Long> |
getBytesList(java.lang.String path)
Gets a list value with elements representing a size in
bytes.
|
Config |
getConfig(java.lang.String path) |
java.util.List<? extends Config> |
getConfigList(java.lang.String path)
Gets a list value with
Config elements. |
double |
getDouble(java.lang.String path) |
java.util.List<java.lang.Double> |
getDoubleList(java.lang.String path)
Gets a list value with double elements.
|
java.time.Duration |
getDuration(java.lang.String path)
Gets a value as a java.time.Duration.
|
long |
getDuration(java.lang.String path,
java.util.concurrent.TimeUnit unit)
Gets a value as a duration in a specified
TimeUnit . |
java.util.List<java.time.Duration> |
getDurationList(java.lang.String path)
Gets a list, converting each value in the list to a duration, using the
same rules as
getDuration(String) . |
java.util.List<java.lang.Long> |
getDurationList(java.lang.String path,
java.util.concurrent.TimeUnit unit)
Gets a list, converting each value in the list to a duration, using the
same rules as
getDuration(String, TimeUnit) . |
<T extends java.lang.Enum<T>> |
getEnum(java.lang.Class<T> enumClass,
java.lang.String path) |
<T extends java.lang.Enum<T>> |
getEnumList(java.lang.Class<T> enumClass,
java.lang.String path)
Gets a list value with
Enum elements. |
int |
getInt(java.lang.String path)
Gets the integer at the given path.
|
java.util.List<java.lang.Integer> |
getIntList(java.lang.String path)
Gets a list value with int elements.
|
boolean |
getIsNull(java.lang.String path)
Checks whether a value is set to null at the given path,
but throws an exception if the value is entirely
unset.
|
ConfigList |
getList(java.lang.String path)
Gets a list value (with any element type) as a
ConfigList , which
implements java.util.List<ConfigValue> . |
long |
getLong(java.lang.String path)
Gets the long integer at the given path.
|
java.util.List<java.lang.Long> |
getLongList(java.lang.String path)
Gets a list value with long elements.
|
ConfigMemorySize |
getMemorySize(java.lang.String path)
Gets a value as an amount of memory (parses special strings like "128M").
|
java.util.List<ConfigMemorySize> |
getMemorySizeList(java.lang.String path)
Gets a list, converting each value in the list to a memory size, using the
same rules as
getMemorySize(String) . |
java.lang.Long |
getMilliseconds(java.lang.String path)
Deprecated.
As of release 1.1, replaced by
getDuration(String, TimeUnit) |
java.util.List<java.lang.Long> |
getMillisecondsList(java.lang.String path)
Deprecated.
As of release 1.1, replaced by
getDurationList(String, TimeUnit) |
java.lang.Long |
getNanoseconds(java.lang.String path)
Deprecated.
As of release 1.1, replaced by
getDuration(String, TimeUnit) |
java.util.List<java.lang.Long> |
getNanosecondsList(java.lang.String path)
Deprecated.
As of release 1.1, replaced by
getDurationList(String, TimeUnit) |
java.lang.Number |
getNumber(java.lang.String path) |
java.util.List<java.lang.Number> |
getNumberList(java.lang.String path)
Gets a list value with number elements.
|
ConfigObject |
getObject(java.lang.String path) |
java.util.List<? extends ConfigObject> |
getObjectList(java.lang.String path)
Gets a list value with object elements.
|
java.time.Period |
getPeriod(java.lang.String path)
Gets a value as a java.time.Period.
|
java.lang.String |
getString(java.lang.String path) |
java.util.List<java.lang.String> |
getStringList(java.lang.String path)
Gets a list value with string elements.
|
java.time.temporal.TemporalAmount |
getTemporal(java.lang.String path)
Gets a value as a java.time.temporal.TemporalAmount.
|
ConfigValue |
getValue(java.lang.String path)
Gets the value at the given path, unless the value is a
null value or missing, in which case it throws just like
the other getters.
|
boolean |
hasPath(java.lang.String path)
Checks whether a value is present and non-null at the given path.
|
boolean |
hasPathOrNull(java.lang.String path)
Checks whether a value is present at the given path, even
if the value is null.
|
boolean |
isEmpty()
Returns true if the
Config 's root object contains no key-value
pairs. |
boolean |
isResolved()
Checks whether the config is completely resolved.
|
ConfigOrigin |
origin()
Gets the origin of the
Config , which may be a file, or a file
with a line number, or just a descriptive phrase. |
Config |
resolve()
Returns a replacement config with all substitutions (the
${foo.bar} syntax, see the
spec) resolved. |
Config |
resolve(ConfigResolveOptions options)
Like
resolve() but allows you to specify non-default
options. |
Config |
resolveWith(Config source)
Like
resolve() except that substitution values are looked
up in the given source, rather than in this instance. |
Config |
resolveWith(Config source,
ConfigResolveOptions options)
Like
resolveWith(Config) but allows you to specify
non-default options. |
ConfigObject |
root()
Gets the
Config as a tree of ConfigObject . |
Config |
withFallback(ConfigMergeable other)
Returns a new value computed by merging this value with another, with
keys in this value "winning" over the other one.
|
Config |
withOnlyPath(java.lang.String path)
Clone the config with only the given path (and its children) retained;
all sibling paths are removed.
|
Config |
withoutPath(java.lang.String path)
Clone the config with the given path removed.
|
Config |
withValue(java.lang.String path,
ConfigValue value)
Returns a
Config based on this one, but with the given path set
to the given value. |
root()
Config
as a tree of ConfigObject
. This is a
constant-time operation (it is not proportional to the number of values
in the Config
).origin()
Config
, which may be a file, or a file
with a line number, or just a descriptive phrase.Config
for use in error messageswithFallback(ConfigMergeable other)
ConfigMergeable
This associative operation may be used to combine configurations from multiple sources (such as multiple configuration files).
The semantics of merging are described in the spec for HOCON. Merging typically occurs when either the same object is created twice in the same file, or two config files are both loaded. For example:
foo = { a: 42 } foo = { b: 43 }Here, the two objects are merged as if you had written:
foo = { a: 42, b: 43 }
Only ConfigObject
and Config
instances do anything in
this method (they need to merge the fallback keys into themselves). All
other values just return the original value, since they automatically
override any fallback. This means that objects do not merge "across"
non-objects; if you write
object.withFallback(nonObject).withFallback(otherObject)
,
then otherObject
will simply be ignored. This is an
intentional part of how merging works, because non-objects such as
strings and integers replace (rather than merging with) any prior value:
foo = { a: 42 } foo = 10Here, the number 10 "wins" and the value of
foo
would be
simply 10. Again, for details see the spec.withFallback
in interface ConfigMergeable
other
- an object whose keys should be used as fallbacks, if the keys
are not present in this oneresolve()
${foo.bar}
syntax, see the
spec) resolved. Substitutions are looked up using this
Config
as the root object, that is, a substitution
${foo.bar}
will be replaced with the result of
getValue("foo.bar")
.
This method uses ConfigResolveOptions.defaults()
, there is
another variant resolve(ConfigResolveOptions)
which lets
you specify non-default options.
A given Config
must be resolved before using it to retrieve
config values, but ideally should be resolved one time for your entire
stack of fallbacks (see withFallback(com.typesafe.config.ConfigMergeable)
). Otherwise, some
substitutions that could have resolved with all fallbacks available may
not resolve, which will be potentially confusing for your application's
users.
resolve()
should be invoked on root config objects, rather
than on a subtree (a subtree is the result of something like
config.getConfig("foo")
). The problem with
resolve()
on a subtree is that substitutions are relative to
the root of the config and the subtree will have no way to get values
from the root. For example, if you did
config.getConfig("foo").resolve()
on the below config file,
it would not work:
common-value = 10 foo { whatever = ${common-value} }
Many methods on ConfigFactory
such as
ConfigFactory.load()
automatically resolve the loaded
Config
on the loaded stack of config files.
Resolving an already-resolved config is a harmless no-op, but again, it is best to resolve an entire stack of fallbacks (such as all your config files combined) rather than resolving each one individually.
ConfigException.UnresolvedSubstitution
- if any substitutions refer to nonexistent pathsConfigException
- some other config exception if there are other problemsresolve(ConfigResolveOptions options)
resolve()
but allows you to specify non-default
options.options
- resolve optionsConfig
(may be only partially resolved if options are set to allow unresolved)boolean isResolved()
resolve()
it will be completely resolved, but after
calling resolve(ConfigResolveOptions)
with
allowUnresolved
set in the options, it may or may not be
completely resolved. A newly-loaded config may or may not be completely
resolved depending on whether there were substitutions present in the
file.resolveWith(Config source)
resolve()
except that substitution values are looked
up in the given source, rather than in this instance. This is a
special-purpose method which doesn't make sense to use in most cases;
it's only needed if you're constructing some sort of app-specific custom
approach to configuration. The more usual approach if you have a source
of substitution values would be to merge that source into your config
stack using withFallback(com.typesafe.config.ConfigMergeable)
and then resolve.
Note that this method does NOT look in this instance for substitution
values. If you want to do that, you could either merge this instance into
your value source using withFallback(com.typesafe.config.ConfigMergeable)
, or you could resolve
multiple times with multiple sources (using
ConfigResolveOptions.setAllowUnresolved(boolean)
so the partial
resolves don't fail).
source
- configuration to pull values fromConfigException.UnresolvedSubstitution
- if any substitutions refer to paths which are not in the
sourceConfigException
- some other config exception if there are other problemsresolveWith(Config source, ConfigResolveOptions options)
resolveWith(Config)
but allows you to specify
non-default options.source
- source configuration to pull values fromoptions
- resolve optionsConfig
(may be only partially resolved
if options are set to allow unresolved)void checkValid(Config reference, java.lang.String... restrictToPaths)
Using this method is always optional, since you can "fail late" instead.
You must restrict validation to paths you "own" (those whose meaning are defined by your code module). If you validate globally, you may trigger errors about paths that happen to be in the config but have nothing to do with your module. It's best to allow the modules owning those paths to validate them. Also, if every module validates only its own stuff, there isn't as much redundant work being done.
If no paths are specified in checkValid()
's parameter list,
validation is for the entire config.
If you specify paths that are not in the reference config, those paths are ignored. (There's nothing to validate.)
Here's what validation involves:
getMilliseconds(java.lang.String)
). Also,
it's allowed to set any type to null or override null with any type.
If you want to allow a certain setting to have a flexible type (or otherwise want validation to be looser for some settings), you could either remove the problematic setting from the reference config provided to this method, or you could intercept the validation exception and screen out certain problems. Of course, this will only work if all other callers of this method are careful to restrict validation to their own paths, as they should be.
If validation fails, the thrown exception contains a list of all problems
found. See ConfigException.ValidationFailed.problems
. The
exception's getMessage()
will have all the problems
concatenated into one huge string, as well.
Again, checkValid()
can't guess every domain-specific way a
setting can be invalid, so some problems may arise later when attempting
to use the config. checkValid()
is limited to reporting
generic, but common, problems such as missing settings and blatant type
incompatibilities.
reference
- a reference configurationrestrictToPaths
- only validate values underneath these paths that your code
module owns and understandsConfigException.ValidationFailed
- if there are any validation issuesConfigException.NotResolved
- if this config is not resolvedConfigException.BugOrBroken
- if the reference config is unresolved or caller otherwise
misuses the APIboolean hasPath(java.lang.String path)
Map.containsKey()
as implemented by
ConfigObject
: it looks for a path expression, not a key; and it
returns false for null values, while containsKey()
returns true
indicating that the object contains a null value for the key.
If a path exists according to hasPath(String)
, then
getValue(String)
will never throw an exception. However, the
typed getters, such as getInt(String)
, will still throw if the
value is not convertible to the requested type.
Note that path expressions have a syntax and sometimes require quoting
(see ConfigUtil.joinPath(java.lang.String...)
and ConfigUtil.splitPath(java.lang.String)
).
path
- the path expressionConfigException.BadPath
- if the path expression is invalidboolean hasPathOrNull(java.lang.String path)
Config
will throw if you try to get a null
value, so if you plan to call getValue(String)
,
getInt(String)
, or another getter you may want to
use plain hasPath(String)
rather than this method.
To handle all three cases (unset, null, and a non-null value) the code might look like:
if (config.hasPathOrNull(path)) {
if (config.getIsNull(path)) {
// handle null setting
} else {
// get and use non-null setting
}
} else {
// handle entirely unset path
}
However, the usual thing is to allow entirely unset
paths to be a bug that throws an exception (because you set
a default in your reference.conf
), so in that
case it's OK to call getIsNull(String)
without
checking hasPathOrNull
first.
Note that path expressions have a syntax and sometimes require quoting
(see ConfigUtil.joinPath(java.lang.String...)
and ConfigUtil.splitPath(java.lang.String)
).
path
- the path expressionConfigException.BadPath
- if the path expression is invalidboolean isEmpty()
Config
's root object contains no key-value
pairs.java.util.Set<java.util.Map.Entry<java.lang.String,entrySet()
the root object
. Note that this is very
different from root().entrySet()
which returns the set of
immediate-child keys in the root object and includes null values.
Entries contain path expressions meaning there may be quoting
and escaping involved. Parse path expressions with
ConfigUtil.splitPath(java.lang.String)
.
Because a Config
is conceptually a single-level map from
paths to values, there will not be any ConfigObject
values in the
entries (that is, all entries represent leaf nodes). Use
ConfigObject
rather than Config
if you want a tree.
(OK, this is a slight lie: Config
entries may contain
ConfigList
and the lists may contain objects. But no objects are
directly included as entry values.)
ConfigObject
and creating an entry for
each leaf value.boolean getIsNull(java.lang.String path)
hasPathOrNull(String)
returned true for the same path, so
to avoid any possible exception check
hasPathOrNull()
first. However, an exception
for unset paths will usually be the right thing (because a
reference.conf
should exist that has the path
set, the path should never be unset unless something is
broken).
Note that path expressions have a syntax and sometimes require quoting
(see ConfigUtil.joinPath(java.lang.String...)
and ConfigUtil.splitPath(java.lang.String)
).
path
- the path expressionConfigException.BadPath
- if the path expression is invalidConfigException.Missing
- if value is not set at allboolean getBoolean(java.lang.String path)
path
- path expressionConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to booleanjava.lang.Number getNumber(java.lang.String path)
path
- path expressionConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to a numberint getInt(java.lang.String path)
path
- path expressionConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to an int (for example it is out
of range, or it's a boolean value)long getLong(java.lang.String path)
path
- path expressionConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to a longdouble getDouble(java.lang.String path)
path
- path expressionConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to a doublejava.lang.String getString(java.lang.String path)
path
- path expressionConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to a string<T extends java.lang.Enum<T>> T getEnum(java.lang.Class<T> enumClass, java.lang.String path)
T
- a generic denoting a specific type of enumenumClass
- an enum classpath
- path expressionEnum
value at the requested path
of the requested enum classConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to an EnumgetObject(java.lang.String path)
path
- path expressionConfigObject
value at the requested pathConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to an objectgetConfig(java.lang.String path)
path
- path expressionConfig
value at the requested pathConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to a Configjava.lang.Object getAnyRef(java.lang.String path)
Boolean
, Integer
, and
so on - see ConfigValue.unwrapped()
).path
- path expressionConfigException.Missing
- if value is absent or nullgetValue(java.lang.String path)
get()
on the root()
object (or other object in the tree) if you
want an unprocessed value.path
- path expressionConfigException.Missing
- if value is absent or nulljava.lang.Long getBytes(java.lang.String path)
path
- path expressionConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to Long or StringConfigException.BadValue
- if value cannot be parsed as a size in bytesgetMemorySize(java.lang.String path)
path
- path expressionConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to Long or StringConfigException.BadValue
- if value cannot be parsed as a size in bytes@Deprecated java.lang.Long getMilliseconds(java.lang.String path)
getDuration(String, TimeUnit)
path
- path expressionConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to Long or StringConfigException.BadValue
- if value cannot be parsed as a number of milliseconds@Deprecated java.lang.Long getNanoseconds(java.lang.String path)
getDuration(String, TimeUnit)
getDuration(String, TimeUnit)
.path
- path expressionConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to Long or StringConfigException.BadValue
- if value cannot be parsed as a number of nanosecondslong getDuration(java.lang.String path, java.util.concurrent.TimeUnit unit)
TimeUnit
. If the value is already a
number, then it's taken as milliseconds and then converted to the
requested TimeUnit; if it's a string, it's parsed understanding units
suffixes like "10m" or "5ns" as documented in the the
spec.path
- path expressionunit
- convert the return value to this time unitConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to Long or StringConfigException.BadValue
- if value cannot be parsed as a number of the given TimeUnitjava.time.Duration getDuration(java.lang.String path)
path
- path expressionConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to Long or StringConfigException.BadValue
- if value cannot be parsed as a number of the given TimeUnitjava.time.Period getPeriod(java.lang.String path)
path
- path expressionConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to Long or StringConfigException.BadValue
- if value cannot be parsed as a number of the given TimeUnitjava.time.temporal.TemporalAmount getTemporal(java.lang.String path)
path
- path expressionConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to Long or StringConfigException.BadValue
- if value cannot be parsed as a TemporalAmountgetList(java.lang.String path)
ConfigList
, which
implements java.util.List<ConfigValue>
. Throws if the path is
unset or null.path
- the path to the list value.ConfigList
at the pathConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to a ConfigListjava.util.List<java.lang.Boolean> getBooleanList(java.lang.String path)
path
- the path to the list value.ConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to a list of booleansjava.util.List<java.lang.Number> getNumberList(java.lang.String path)
path
- the path to the list value.ConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to a list of numbersjava.util.List<java.lang.Integer> getIntList(java.lang.String path)
path
- the path to the list value.ConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to a list of intsjava.util.List<java.lang.Long> getLongList(java.lang.String path)
path
- the path to the list value.ConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to a list of longsjava.util.List<java.lang.Double> getDoubleList(java.lang.String path)
path
- the path to the list value.ConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to a list of doublesjava.util.List<java.lang.String> getStringList(java.lang.String path)
path
- the path to the list value.ConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to a list of strings<T extends java.lang.Enum<T>> java.util.List<T> getEnumList(java.lang.Class<T> enumClass, java.lang.String path)
Enum
elements. Throws if the
path is unset or null or not a list or contains values not
convertible to Enum
.T
- a generic denoting a specific type of enumenumClass
- the enum classpath
- the path to the list value.ConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to a list of Enum
java.util.List<? extends getObjectList(java.lang.String path)
ConfigObject
.path
- the path to the list value.ConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to a list of objectsjava.util.List<? extends getConfigList(java.lang.String path)
Config
elements.
Throws if the path is unset or null or not a list or
contains values not convertible to Config
.path
- the path to the list value.ConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to a list of configsjava.util.List<? extends java.lang.Object> getAnyRefList(java.lang.String path)
ConfigValue.unwrapped()
).path
- the path to the list value.ConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to a listjava.util.List<java.lang.Long> getBytesList(java.lang.String path)
path
- the path to the list value.ConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to a list of memory sizesjava.util.List<getMemorySizeList(java.lang.String path)
getMemorySize(String)
.path
- a path expressionConfigException.Missing
- if value is absent or nullConfigException.WrongType
- if value is not convertible to a list of memory sizes@Deprecated java.util.List<java.lang.Long> getMillisecondsList(java.lang.String path)
getDurationList(String, TimeUnit)
path
- the path@Deprecated java.util.List<java.lang.Long> getNanosecondsList(java.lang.String path)
getDurationList(String, TimeUnit)
path
- the pathjava.util.List<java.lang.Long> getDurationList(java.lang.String path, java.util.concurrent.TimeUnit unit)
getDuration(String, TimeUnit)
.path
- a path expressionunit
- time units of the returned valuesjava.util.List<java.time.Duration> getDurationList(java.lang.String path)
getDuration(String)
.path
- a path expressionwithOnlyPath(java.lang.String path)
Note that path expressions have a syntax and sometimes require quoting
(see ConfigUtil.joinPath(java.lang.String...)
and ConfigUtil.splitPath(java.lang.String)
).
path
- path to keepwithoutPath(java.lang.String path)
Note that path expressions have a syntax and sometimes require quoting
(see ConfigUtil.joinPath(java.lang.String...)
and ConfigUtil.splitPath(java.lang.String)
).
path
- path expression to removeatPath(java.lang.String path)
Config
at the given path.
Note that path expressions have a syntax and sometimes require quoting
(see ConfigUtil.joinPath(java.lang.String...)
and ConfigUtil.splitPath(java.lang.String)
).
path
- path expression to store this config at.Config
instance containing this config at the given
path.atKey(java.lang.String key)
Config
at the given key. See also
atPath(). Note that a key is NOT a path expression (see
ConfigUtil.joinPath(java.lang.String...)
and ConfigUtil.splitPath(java.lang.String)
).key
- key to store this config at.Config
instance containing this config at the given
key.withValue(java.lang.String path, ConfigValue value)
Config
based on this one, but with the given path set
to the given value. Does not modify this instance (since it's immutable).
If the path already has a value, that value is replaced. To remove a
value, use withoutPath().
Note that path expressions have a syntax and sometimes require quoting
(see ConfigUtil.joinPath(java.lang.String...)
and ConfigUtil.splitPath(java.lang.String)
).
path
- path expression for the value's new locationvalue
- value at the new path