Configurations
in package
Uses
NotInstanciable
Functions on Configuration instances and factories.
Tags
Table of Contents
Methods
- builder() : TreeConfigurationBuilder
- Gets a new TreeConfigBuilder instance.
- doOnRead() : Configuration<K, V>
- Decorates a configuration to do an action when a value is read (only with interpolation).
- doOnUnset() : Configuration<K, V>
- Decorates a configuration to do an action when an entry is unset (the entry may be absent).
- emptyChild() : Configuration<K, V>
- Creates a new Configuration instance that inherit all data from $parent.
- emptyTreeCopyOf() : Configuration
- Makes a copy instance conserving the interpolator but not the entries.
- hierarchy() : Configuration<mixed, mixed>
- Creates a new Configuration instance that inherit all data from a sequence of parents.
- mapOnRead() : Configuration<K, MV>
- Decorates a configuration to do an mapping when a value is read.
- mapOnSet() : Configuration<MK, MV>
- Decorates a configuration to do a mapping on (key => value) entry before their assignment.
- merge() : void
- Copies an iterable's entries into a configuration destination, that is copy all the (key => value) pairs from $src into $dest.
- mergeTree() : void
- Merges all levels of tree-shaped data source within a Configuration instance destination.
- ofTree() : Configuration<string|int, V>
- Makes a configuration from trees-structured arrays.
- rawTreeCopyOf() : Configuration
- Makes a copy conserving the interpolation.
- treeCopyOf() : Configuration
- Makes a copy of the configuration tree.
- union() : void
- Copies the entries of a sequence data source into a Configuration instance destination, that is copy all the (key => value) pairs from $src into $dest.
- unmodifiable() : Configuration
- Makes a configuration unmodifiable.
Methods
builder()
Gets a new TreeConfigBuilder instance.
public
static builder() : TreeConfigurationBuilder
Return values
TreeConfigurationBuilder —A new instance.
doOnRead()
Decorates a configuration to do an action when a value is read (only with interpolation).
public
static doOnRead(Configuration<K, V> $config, Consumer<K, V> $do) : Configuration<K, V>
Parameters
- $config : Configuration<K, V>
-
The base configuration to decorate.
- $do : Consumer<K, V>
-
The action to do.
Tags
Return values
Configuration<K, V> —A new configuration instance wrapping the base configuration.
doOnUnset()
Decorates a configuration to do an action when an entry is unset (the entry may be absent).
public
static doOnUnset(Configuration<K, V> $config, Consumer<K, V> $do) : Configuration<K, V>
Parameters
- $config : Configuration<K, V>
-
The base configuration to decorate.
- $do : Consumer<K, V>
-
The mapping to do.
Tags
Return values
Configuration<K, V> —A new configuration instance wrapping the base configuration.
emptyChild()
Creates a new Configuration instance that inherit all data from $parent.
public
static emptyChild(Configuration<K, V> $parent) : Configuration<K, V>
The $parent instance defines default values for the new Configuration instance that always exist. The default values can be shadowed by that in the new instance.
Note that the parent instance is assigned as it (ie. reference), that is it may always be modified outside the hierarchy instance.
Parameters
- $parent : Configuration<K, V>
-
The parent configuration to use.
Tags
Return values
Configuration<K, V> —A new Configuration instance where the parent tree is not modifiable.
emptyTreeCopyOf()
Makes a copy instance conserving the interpolator but not the entries.
public
static emptyTreeCopyOf(Configuration $config) : Configuration
Parameters
- $config : Configuration
-
The configuration to copy from.
Return values
Configuration —A new Configuration instance.
hierarchy()
Creates a new Configuration instance that inherit all data from a sequence of parents.
public
static hierarchy(Configuration<mixed, mixed> $parent, Configuration<mixed, mixed> ...$childs) : Configuration<mixed, mixed>
The [$parent,...$childs] instances defines default values for the new Configuration instance that always exist. The default values can be shadowed by that in the new instance.
The order of the parents in the sequence is signifiant: the last parents shadowed the previous in case of common branches. Note that the parents instances are assigned as it (ie. references), that is they may always be modified outside the hierarchy instance.
Parameters
- $parent : Configuration<mixed, mixed>
-
The first parent of the sequence.
- $childs : Configuration<mixed, mixed>
-
More parents of the sequence.
Return values
Configuration<mixed, mixed> —A new Configuration hierarchy instance.
mapOnRead()
Decorates a configuration to do an mapping when a value is read.
public
static mapOnRead(Configuration<K, V> $config, MapValue<V, MV> $map[, iterable<string|int, ReadingMode>|null $mapOnReadingMode = null ]) : Configuration<K, MV>
Parameters
- $config : Configuration<K, V>
-
The base configuration to decorate.
- $map : MapValue<V, MV>
-
The mapping to do.
- $mapOnReadingMode : iterable<string|int, ReadingMode>|null = null
-
Only do the mapping for the specified s. If not set then the only allowed mode is
Tags
Return values
Configuration<K, MV> —A new configuration instance wrapping the base configuration.
mapOnSet()
Decorates a configuration to do a mapping on (key => value) entry before their assignment.
public
static mapOnSet(Configuration<K, V> $config, Map<MK, MV> $map) : Configuration<MK, MV>
Parameters
- $config : Configuration<K, V>
-
The base configuration to decorate.
- $map : Map<MK, MV>
-
The mapping to do on an entry before its storage.
Tags
Return values
Configuration<MK, MV> —A new configuration instance wrapping the base configuration.
merge()
Copies an iterable's entries into a configuration destination, that is copy all the (key => value) pairs from $src into $dest.
public
static merge(Configuration<K, V> $dest, iterable<K, V> ...$sources) : void
If an entry to copy is already present in the configuration then the entry is copied and override the previous entry.
Parameters
- $dest : Configuration<K, V>
- $sources : iterable<K, V>
Tags
mergeTree()
Merges all levels of tree-shaped data source within a Configuration instance destination.
public
static mergeTree(Configuration<K, V> $dest, array<string|int, V> ...$trees) : void
The merge occurs recursively with the sub-data of the source. If an array sub-data is a list, then the list is considered as a simple value and the recursion stop.
Parameters
- $dest : Configuration<K, V>
- $trees : array<string|int, V>
Tags
ofTree()
Makes a configuration from trees-structured arrays.
public
static ofTree(array<string|int, V> ...$trees) : Configuration<string|int, V>
If some trees share some same branches then the last tree branches override the previous ones.
Parameters
- $trees : array<string|int, V>
-
The trees to consider.
Tags
Return values
Configuration<string|int, V> —A new Configuration instance.
rawTreeCopyOf()
Makes a copy conserving the interpolation.
public
static rawTreeCopyOf(Configuration $config) : Configuration
Parameters
- $config : Configuration
-
The configuration to copy from.
Return values
Configuration —A new Configuration instance.
treeCopyOf()
Makes a copy of the configuration tree.
public
static treeCopyOf(Configuration $config[, Interpolator $interpolator = null ]) : Configuration
Parameters
- $config : Configuration
-
The configuration to copy from.
- $interpolator : Interpolator = null
-
If not set (ie. null) the copy will contains the interpolated value of the configuration tree. If set the copy will use this interpolator on the raw base value to create a new interpolated configuration.$this Note that the interpolator may be the same as $config, in that case it means that the base interpolation is conserved.
Return values
Configuration —A new Configuration instance.
union()
Copies the entries of a sequence data source into a Configuration instance destination, that is copy all the (key => value) pairs from $src into $dest.
public
static union(Configuration<K, V> $dest, iterable<K, V> ...$sources) : void
If an entry to copy is already present in the configuration then the entry is not copied, the first entry stay in place.
Parameters
- $dest : Configuration<K, V>
- $sources : iterable<K, V>
Tags
unmodifiable()
Makes a configuration unmodifiable.
public
static unmodifiable(Configuration $config) : Configuration
The unmodifiable behaviour is implemented as a decorator wrapping around the the base configuration, that is if the base configuration may have updates outside the unmodifiable decorator.
Parameters
- $config : Configuration
-
The configuration to wrap unmodifiable.
Return values
Configuration —The unmodifiable instance.