public class ExtendedSettings extends Settings
Config
object, which supports to represent inner maps as extensions
.
Using the typesafe config library, several several sources can be loaded into a single config object. These sources will be merged together, so that extensions like the following will be put into one extension list reachable as "examples":
File A:
examples {
A = {
key = "string"
otherKey = true
}
}
File B:
examples {
B = {
key = "string"
otherKey = true
}
}
This permits frameworks to provide extension hooks which can be extended by sub modules, without having the framework to "know" those modules. Using a loose coupled approach like this simplifies the task of building modular and extensible systems.
The extensions defined above can be obtained calling settings.getExtension("examples")
. Each
of those extensions can be read out calling ext.getValue("key").asString()
or
ext.getValue("otherKey").asBoolean()
Extension
Modifier and Type | Field and Description |
---|---|
static Pattern |
VALID_EXTENSION_ID
Provides a regular expression which verifies if an extension name is well formed.
|
Constructor and Description |
---|
ExtendedSettings(com.typesafe.config.Config config) |
Modifier and Type | Method and Description |
---|---|
protected Extension |
getDefault(String type) |
Extension |
getExtension(String type,
String id)
Returns the Extension for the given id of the given type
|
Collection<Extension> |
getExtensions(String type)
Returns all extensions available for the given type
The order of the extensions can be defined, setting a property named priority.
|
get, getConfig, getConfig, getConfigs, getContext, getInt, getMap, getMilliseconds, getString, getStringList, injectValueFromConfig
public static final Pattern VALID_EXTENSION_ID
@Nullable public Extension getExtension(String type, String id)
type
- the type of the extension to be returnedid
- the unique id of the extension to be returned@Nonnull public Collection<Extension> getExtensions(String type)
The order of the extensions can be defined, setting a property named priority. If no value is
present PriorityCollector.DEFAULT_PRIORITY
is assumed.
type
- the type of the extensions to be returned.Copyright © 2018. All rights reserved.