public final class ConfigSources
extends java.lang.Object
ConfigSource
implementations.ConfigSource
Modifier and Type | Class | Description |
---|---|---|
static class |
ConfigSources.CompositeBuilder |
Builder of a
ConfigSource that encapsulates multiple separate
ConfigSource s. |
static class |
ConfigSources.MapBuilder |
Builder of a
ConfigSource based on a Map containing
config entries. |
static interface |
ConfigSources.MergingStrategy |
An algorithm for combining multiple
ConfigNode.ObjectNode root nodes
into a single ConfigNode.ObjectNode root node. |
Modifier and Type | Method | Description |
---|---|---|
static AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,java.nio.file.Path>,java.nio.file.Path> |
classpath(java.lang.String resource) |
Provides a
Builder for creating a ConfigSource
from the specified resource located on the classpath of the current
thread's context classloader. |
static AbstractConfigSource.Builder<? extends AbstractConfigSource.Builder<?,java.nio.file.Path>,java.nio.file.Path> |
directory(java.lang.String path) |
Provides a
Builder for creating a ConfigSource from the specified
directory path. |
static ConfigSource |
empty() |
Provides an empty config source.
|
static ConfigSource |
environmentVariables() |
Provides a @{code ConfigSource} for creating a
Config from
environment variables. |
static AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,java.nio.file.Path>,java.nio.file.Path> |
file(java.lang.String path) |
Provides a
Builder for creating a ConfigSource from the specified
file path. |
static ConfigSource |
from(Config config) |
Returns a
ConfigSource that contains the same configuration model
as the provided config . |
static ConfigSource |
from(ConfigNode.ObjectNode objectNode) |
Returns a
ConfigSource that wraps the specified objectNode
and returns it when Source.load() is invoked. |
static ConfigSource |
from(java.lang.Readable readable,
java.lang.String mediaType) |
|
static ConfigSource |
from(java.lang.String content,
java.lang.String mediaType) |
|
static ConfigSources.CompositeBuilder |
from(java.util.function.Supplier<ConfigSource>... configSources) |
Provides a
ConfigSources.CompositeBuilder for creating a composite
ConfigSource based on the specified ConfigSource s, used
in the order in which they are passed as arguments. |
static ConfigSources.CompositeBuilder |
from(java.util.List<java.util.function.Supplier<ConfigSource>> configSources) |
Provides a
ConfigSources.CompositeBuilder for creating a composite
ConfigSource based on the ConfigSource s and their order
in the specified list. |
static ConfigSources.MapBuilder |
from(java.util.Map<java.lang.String,java.lang.String> map) |
|
static ConfigSources.MapBuilder |
from(java.util.Properties properties) |
|
static ConfigSources.CompositeBuilder |
load(Config metaConfig) |
Provides a
ConfigSources.CompositeBuilder for creating a composite
ConfigSource based on the ConfigSource s returned by the
provided meta-configuration. |
static ConfigSources.CompositeBuilder |
load(java.util.function.Supplier<ConfigSource>... metaSources) |
Provides a
ConfigSources.CompositeBuilder for creating a composite
ConfigSource based on the ConfigSource s returned by the
provided meta-sources. |
static ConfigSource |
prefixed(java.lang.String key,
java.util.function.Supplier<ConfigSource> sourceSupplier) |
Provides a
ConfigSource from a sourceSupplier , adding the
specified prefix to the keys in the source. |
static ConfigSource |
systemProperties() |
Provides a
ConfigSource for creating a Config derived
from system properties. |
static AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,java.net.URL>,java.net.URL> |
url(java.net.URL url) |
Provides a
Builder for creating a ConfigSource from the specified
URL. |
public static ConfigSource empty()
public static ConfigSource from(Config config)
ConfigSource
that contains the same configuration model
as the provided config
.config
- the original Config
ConfigSource
for the same Config
as the originalpublic static ConfigSource from(ConfigNode.ObjectNode objectNode)
ConfigSource
that wraps the specified objectNode
and returns it when Source.load()
is invoked.objectNode
- hierarchical configuration representation that will be
returned by Source.load()
ConfigSource
ConfigNode.ObjectNode
,
ConfigNode.ListNode
,
ConfigNode.ValueNode
,
ConfigNode.ObjectNode.Builder
,
ConfigNode.ListNode.Builder
public static ConfigSource from(java.lang.Readable readable, java.lang.String mediaType)
ConfigSource
from the provided readable content
and
with the specified mediaType
.
Instant.now()
is the content timestamp
.
readable
- a Readable
providing the configuration contentmediaType
- a configuration media typepublic static ConfigSource from(java.lang.String content, java.lang.String mediaType)
ConfigSource
from the provided String
content and
with the specified mediaType
.
Instant.now()
is the content timestamp
.
content
- a configuration contentmediaType
- a configuration media typepublic static ConfigSources.MapBuilder from(java.util.Map<java.lang.String,java.lang.String> map)
map
- a mapfrom(Properties)
public static ConfigSources.MapBuilder from(java.util.Properties properties)
properties
- propertiesfrom(Map)
public static ConfigSource prefixed(java.lang.String key, java.util.function.Supplier<ConfigSource> sourceSupplier)
ConfigSource
from a sourceSupplier
, adding the
specified prefix
to the keys in the source.key
- key prefix to be added to all keyssourceSupplier
- a config source supplierpublic static ConfigSource systemProperties()
ConfigSource
for creating a Config
derived
from system properties.ConfigSource
for config derived from system propertiespublic static ConfigSource environmentVariables()
Config
from
environment variables.ConfigSource
for config derived from environment variablespublic static AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,java.nio.file.Path>,java.nio.file.Path> classpath(java.lang.String resource)
Builder
for creating a ConfigSource
from the specified resource located on the classpath of the current
thread's context classloader.
The name of a resource is a '/
'-separated full path name that
identifies the resource. If the resource name has a leading slash then it
is dropped before lookup.
resource
- a name of the resourceConfigSource
for the classpath-based resourcepublic static AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,java.nio.file.Path>,java.nio.file.Path> file(java.lang.String path)
Builder
for creating a ConfigSource
from the specified
file path.path
- a file pathConfigSource
public static AbstractConfigSource.Builder<? extends AbstractConfigSource.Builder<?,java.nio.file.Path>,java.nio.file.Path> directory(java.lang.String path)
Builder
for creating a ConfigSource
from the specified
directory path.path
- a directory pathpublic static AbstractParsableConfigSource.Builder<? extends AbstractParsableConfigSource.Builder<?,java.net.URL>,java.net.URL> url(java.net.URL url)
Builder
for creating a ConfigSource
from the specified
URL.url
- a URL with configurationurl(URL)
@SafeVarargs public static ConfigSources.CompositeBuilder from(java.util.function.Supplier<ConfigSource>... configSources)
ConfigSources.CompositeBuilder
for creating a composite
ConfigSource
based on the specified ConfigSource
s, used
in the order in which they are passed as arguments.
By default the resulting ConfigSource
combines the various
ConfigSource
s using the system-provided
fallback merging strategy
. The
application can invoke ConfigSources.CompositeBuilder.mergingStrategy
to change
how the sources are combined.
configSources
- original config sources to be treated as oneConfigSources.CompositeBuilder
,
ConfigSources.MergingStrategy
,
from(Supplier[])
,
from(List)
,
load(Supplier[])
,
load(Config)
,
Config.from(Supplier[])
,
Config.withSources(Supplier[])
public static ConfigSources.CompositeBuilder from(java.util.List<java.util.function.Supplier<ConfigSource>> configSources)
ConfigSources.CompositeBuilder
for creating a composite
ConfigSource
based on the ConfigSource
s and their order
in the specified list.
By default the resulting ConfigSource
combines the various
ConfigSource
s using the system-provided
fallback merging strategy
. The
application can invoke ConfigSources.CompositeBuilder.mergingStrategy
to change
how the sources are combined.
configSources
- original config sources to be treated as oneConfigSources.CompositeBuilder
,
ConfigSources.MergingStrategy
,
from(Supplier[])
,
from(List)
,
load(Supplier[])
,
load(Config)
,
Config.from(Supplier[])
,
Config.withSources(Supplier[])
@SafeVarargs public static ConfigSources.CompositeBuilder load(java.util.function.Supplier<ConfigSource>... metaSources)
ConfigSources.CompositeBuilder
for creating a composite
ConfigSource
based on the ConfigSource
s returned by the
provided meta-sources.
Each meta-source must contain the sources
property which is an
array of config sources. See ConfigSource.from(Config)
for more
information about the format of meta-configuration.
The returned builder is a CompositeBuilder
that combines the
config from all config sources derived from the meta-configuration in the
meta-sources. By default the composite builder uses the
fallback merging strategy
.
metaSources
- ordered list of meta-sources from which the builder
will read meta-configuration indicating the config sourcesConfigSources.CompositeBuilder
,
ConfigSources.MergingStrategy
,
from(Supplier[])
,
from(List)
,
load(Supplier[])
,
load(Config)
,
Config.loadSources(Supplier[])
,
Config.loadSourcesFrom(Supplier[])
public static ConfigSources.CompositeBuilder load(Config metaConfig)
ConfigSources.CompositeBuilder
for creating a composite
ConfigSource
based on the ConfigSource
s returned by the
provided meta-configuration.
The meta-configuration must contain the sources
property which is
an array of config sources. See ConfigSource.from(Config)
for
more information about the format of meta-configuration.
The returned builder is a CompositeBuilder
that combines the
config from all config sources derived from the meta-configuration. By
default the composite builder uses the
fallback merging strategy
.
metaConfig
- meta-configuration from which the builder will derive
config sourcesConfigSources.CompositeBuilder
,
ConfigSources.MergingStrategy
,
from(Supplier[])
,
from(List)
,
load(Supplier[])
,
load(Config)
,
Config.loadSources(Supplier[])
,
Config.loadSourcesFrom(Supplier[])
Copyright © 2018 Oracle Corporation. All rights reserved.