Class MultiFileBuilderParametersImpl
java.lang.Object
org.apache.commons.configuration2.builder.BasicBuilderParameters
org.apache.commons.configuration2.builder.combined.MultiFileBuilderParametersImpl
- All Implemented Interfaces:
Cloneable
,BasicBuilderProperties<BasicBuilderParameters>
,BuilderParameters
,MultiFileBuilderProperties<MultiFileBuilderParametersImpl>
public class MultiFileBuilderParametersImpl
extends BasicBuilderParameters
implements MultiFileBuilderProperties<MultiFileBuilderParametersImpl>
A specialized parameters object for MultiFileConfigurationBuilder
.
A parameters object of this type is used by a configuration builder with manages multiple file-based configurations. Such a builder is a bit special because it does not create a configuration on its own, but delegates to a file-based builder for this purpose. Therefore, parameters inherited from the super class are treated differently:
- The
ConfigurationInterpolator
is needed by aMultiFileConfigurationBuilder
to resolve the file pattern. It is expected to be set and will not be passed to sub configurations created by the builder. - All other parameters are evaluated when creating sub configurations. However, it is preferred to use the
setManagedBuilderParameters(BuilderParameters)
method to define all properties of sub configurations in a single place. If such a parameters object is set, its properties take precedence.
This class is not thread-safe. It is intended that an instance is constructed and initialized by a single thread
during configuration of a ConfigurationBuilder
.
- Since:
- 2.0
-
Field Summary
Fields inherited from interface org.apache.commons.configuration2.builder.BuilderParameters
RESERVED_PARAMETER_PREFIX
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Clones this object.fromParameters
(Map<String, Object> params) Obtains an instance of this class from the given map with parameters.fromParameters
(Map<String, Object> params, boolean createIfMissing) Obtains an instance of this class from the given map with parameters and creates a new object if such an instance cannot be found.Gets the pattern for determining file names for managed configurations.Gets the parameters object for managed configuration builders.Gets a map with all parameters defined by this objects.Sets the pattern string.Sets a parameters object to be used when creating a managed configuration.Methods inherited from class org.apache.commons.configuration2.builder.BasicBuilderParameters
copyPropertiesFrom, fetchBeanHelper, fetchInterpolatorSpecification, fetchProperty, inheritFrom, merge, setBeanHelper, setConfigurationDecoder, setConversionHandler, setDefaultLookups, setInterpolator, setListDelimiterHandler, setLogger, setParentInterpolator, setPrefixLookups, setSynchronizer, setThrowExceptionOnMissing, storeProperty
-
Constructor Details
-
MultiFileBuilderParametersImpl
public MultiFileBuilderParametersImpl()
-
-
Method Details
-
fromParameters
Obtains an instance of this class from the given map with parameters. If this map does not contain an instance, result is null. This is equivalent tofromParameters(params, false)
.- Parameters:
params
- the map with parameters (must not be null)- Returns:
- an instance of this class fetched from the map or null
- Throws:
NullPointerException
- if the map with parameters is null
-
fromParameters
public static MultiFileBuilderParametersImpl fromParameters(Map<String, Object> params, boolean createIfMissing) Obtains an instance of this class from the given map with parameters and creates a new object if such an instance cannot be found. This method can be used to obtain an instance from a map which has been created using thegetParameters()
method. If the map does not contain an instance under the expected key and thecreateIfMissing
parameter is true, a new instance is created. Otherwise, result is null.- Parameters:
params
- the map with parameters (must not be null)createIfMissing
- a flag whether a new instance should be created if necessary- Returns:
- an instance of this class fetched from the map or null
- Throws:
NullPointerException
- if the map with parameters is null
-
clone
Clones this object. This is useful because multiple builder instances may use a similar set of parameters. However, single instances of parameter objects must not assigned to multiple builders. Therefore, cloning a parameters object provides a solution for this use case. This method creates a new parameters object with the same content as this one. The internal map storing the parameter values is cloned, too, also collection structures contained in this map. However, no a full deep clone operation is performed. Objects like aConfigurationInterpolator
orLookup
s are shared between this and the newly created instance. This implementation also tries to clone the parameters object for managed builders if possible.- Overrides:
clone
in classBasicBuilderParameters
- Returns:
- a clone of this object
-
getFilePattern
Gets the pattern for determining file names for managed configurations.- Returns:
- the file pattern
-
getManagedBuilderParameters
Gets the parameters object for managed configuration builders.- Returns:
- the parameters for sub configurations
-
getParameters
Gets a map with all parameters defined by this objects. The keys of the map correspond to concrete properties supported by theConfiguration
implementation class the builder produces. The values are the corresponding property values. The return value must not be null. This implementation returns a copy of the internal parameters map with the values set so far. Collection structures (e.g. for lookup objects) are stored as defensive copies, so the original data cannot be modified. This implementation puts a reference to this object under a reserved key in the resulting parameters map.- Specified by:
getParameters
in interfaceBuilderParameters
- Overrides:
getParameters
in classBasicBuilderParameters
- Returns:
- a map with builder parameters
-
setFilePattern
Description copied from interface:MultiFileBuilderProperties
Sets the pattern string. Based on this pattern the configuration file to be loaded is determined.- Specified by:
setFilePattern
in interfaceMultiFileBuilderProperties<MultiFileBuilderParametersImpl>
- Parameters:
p
- the pattern string- Returns:
- a reference to this object for method chaining
-
setManagedBuilderParameters
Description copied from interface:MultiFileBuilderProperties
Sets a parameters object to be used when creating a managed configuration. These parameters configure sub configurations.- Specified by:
setManagedBuilderParameters
in interfaceMultiFileBuilderProperties<MultiFileBuilderParametersImpl>
- Parameters:
p
- the parameters object for a sub configuration- Returns:
- a reference to this object for method chaining
-