public class BasicBuilderParameters extends Object implements Cloneable, BuilderParameters, BasicBuilderProperties<BasicBuilderParameters>
An implementation of BuilderParameters
which handles the parameters of a ConfigurationBuilder
common
to all concrete Configuration
implementations.
This class provides methods for setting standard properties supported by the AbstractConfiguration
base
class. A fluent interface can be used to set property values.
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
.
RESERVED_PARAMETER_PREFIX
Constructor and Description |
---|
BasicBuilderParameters()
Creates a new instance of
BasicBuilderParameters . |
Modifier and Type | Method and Description |
---|---|
BasicBuilderParameters |
clone()
Clones this object.
|
protected void |
copyPropertiesFrom(Map<String,?> source,
String... keys)
Copies a number of properties from the given map into this object.
|
static BeanHelper |
fetchBeanHelper(Map<String,Object> params)
Obtains the
BeanHelper object from the specified map with parameters. |
static InterpolatorSpecification |
fetchInterpolatorSpecification(Map<String,Object> params)
Obtains a specification for a
ConfigurationInterpolator from the specified map with parameters. |
protected Object |
fetchProperty(String key)
Obtains the value of the specified property from the internal map.
|
Map<String,Object> |
getParameters()
Returns a map with all parameters defined by this objects.
|
void |
inheritFrom(Map<String,?> source)
Inherits properties from the specified map.
|
void |
merge(BuilderParameters p)
Merges this object with the given parameters object.
|
BasicBuilderParameters |
setBeanHelper(BeanHelper beanHelper)
Sets a
BeanHelper object to be used by the configuration builder. |
BasicBuilderParameters |
setConfigurationDecoder(ConfigurationDecoder decoder)
Sets the
ConfigurationDecoder object for this configuration. |
BasicBuilderParameters |
setConversionHandler(ConversionHandler handler)
Sets the
ConversionHandler object for this configuration. |
BasicBuilderParameters |
setDefaultLookups(Collection<? extends Lookup> lookups)
Adds additional default
Lookup objects (i.e. |
BasicBuilderParameters |
setInterpolator(ConfigurationInterpolator ci)
Sets the
ConfigurationInterpolator to be used for this configuration. |
BasicBuilderParameters |
setListDelimiterHandler(ListDelimiterHandler handler)
Sets the value of the listDelimiterHandler property.
|
BasicBuilderParameters |
setLogger(ConfigurationLogger log)
Sets the logger property.
|
BasicBuilderParameters |
setParentInterpolator(ConfigurationInterpolator parent)
Sets the parent
ConfigurationInterpolator for this configuration's ConfigurationInterpolator . |
BasicBuilderParameters |
setPrefixLookups(Map<String,? extends Lookup> lookups)
Sets additional
Lookup objects for specific prefixes for this configuration object. |
BasicBuilderParameters |
setSynchronizer(Synchronizer sync)
Sets the
Synchronizer object for this configuration. |
BasicBuilderParameters |
setThrowExceptionOnMissing(boolean b)
Sets the value of the throwExceptionOnMissing property.
|
protected void |
storeProperty(String key,
Object value)
Sets a property for this parameters object.
|
public BasicBuilderParameters()
BasicBuilderParameters
.public Map<String,Object> getParameters()
Configuration
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.getParameters
in interface BuilderParameters
public BasicBuilderParameters setLogger(ConfigurationLogger log)
Log
object can be set for the configuration.
Thus logging behavior can be controlled.setLogger
in interface BasicBuilderProperties<BasicBuilderParameters>
log
- the Log
for the configuration produced by this builderpublic BasicBuilderParameters setThrowExceptionOnMissing(boolean b)
setThrowExceptionOnMissing
in interface BasicBuilderProperties<BasicBuilderParameters>
b
- the value of the propertypublic BasicBuilderParameters setListDelimiterHandler(ListDelimiterHandler handler)
AbstractConfiguration
does not allow setting this
property to null. If the default ListDelimiterHandler
is to be used, do not call this method.setListDelimiterHandler
in interface BasicBuilderProperties<BasicBuilderParameters>
handler
- the ListDelimiterHandler
public BasicBuilderParameters setInterpolator(ConfigurationInterpolator ci)
ConfigurationInterpolator
to be used for this configuration. Using this method a custom
ConfigurationInterpolator
can be set which can be freely configured. Alternatively, it is possible to add
custom Lookup
objects using other methods provided by this interface. The passed in ConfigurationInterpolator
is set without modifications.setInterpolator
in interface BasicBuilderProperties<BasicBuilderParameters>
ci
- the ConfigurationInterpolator
for this configurationpublic BasicBuilderParameters setPrefixLookups(Map<String,? extends Lookup> lookups)
Lookup
objects for specific prefixes for this configuration object. All Lookup
objects contained in the given map are added to the configuration's ConfigurationInterpolator
. Note: This
method only takes effect if no ConfigurationInterpolator
is set using the
BasicBuilderProperties.setInterpolator(ConfigurationInterpolator)
method. A defensive copy of the passed in map is created. A null argument causes all prefix lookups to
be removed from the internal parameters map.setPrefixLookups
in interface BasicBuilderProperties<BasicBuilderParameters>
lookups
- a map with Lookup
objects and their associated prefixesConfigurationInterpolator.registerLookups(Map)
public BasicBuilderParameters setDefaultLookups(Collection<? extends Lookup> lookups)
Lookup
objects (i.e. lookups which are not associated with a specific prefix) to this
configuration object. Note: This method only takes effect if no ConfigurationInterpolator
is set using the
BasicBuilderProperties.setInterpolator(ConfigurationInterpolator)
method. A defensive copy of the passed in collection is created. A null argument causes all default
lookups to be removed from the internal parameters map.setDefaultLookups
in interface BasicBuilderProperties<BasicBuilderParameters>
lookups
- a collection with Lookup
objects to be added as default lookups at the configuration's
ConfigurationInterpolator
ConfigurationInterpolator.addDefaultLookups(Collection)
public BasicBuilderParameters setParentInterpolator(ConfigurationInterpolator parent)
ConfigurationInterpolator
for this configuration's ConfigurationInterpolator
. Setting
a parent ConfigurationInterpolator
can be used for defining a default behavior for variables which cannot be
resolved. This implementation stores the passed in ConfigurationInterpolator
object in the internal
parameters map.setParentInterpolator
in interface BasicBuilderProperties<BasicBuilderParameters>
parent
- the new parent ConfigurationInterpolator
ConfigurationInterpolator.setParentInterpolator(ConfigurationInterpolator)
public BasicBuilderParameters setSynchronizer(Synchronizer sync)
Synchronizer
object for this configuration. This object is used to protect this configuration
instance against concurrent access. The concrete Synchronizer
implementation used determines whether a
configuration instance is thread-safe or not. This implementation stores the passed in Synchronizer
object in the internal parameters map.setSynchronizer
in interface BasicBuilderProperties<BasicBuilderParameters>
sync
- the Synchronizer
to be used (a value of null means that a default Synchronizer
is
used)public BasicBuilderParameters setConversionHandler(ConversionHandler handler)
ConversionHandler
object for this configuration. This object is responsible for all data type
conversions required for accessing configuration properties in a specific target type. If this property is not set, a
default ConversionHandler
is used. This implementation stores the passed in ConversionHandler
object in the internal parameters
map.setConversionHandler
in interface BasicBuilderProperties<BasicBuilderParameters>
handler
- the ConversionHandler
to be usedpublic BasicBuilderParameters setBeanHelper(BeanHelper beanHelper)
BeanHelper
object to be used by the configuration builder. The BeanHelper
is used to create
the managed configuration instance dynamically. It is not a property of the configuration as most other properties
defined by this interface. By setting an alternative BeanHelper
the process of creating configuration
instances via reflection can be adapted. (Some specialized configuration builder implementations also use a
BeanHelper
to create complex helper objects during construction of their result object.
CombinedConfigurationBuilder
for instance supports a complex configuration definition format which may
contain several specialized bean declarations.) If no specific BeanHelper
is set, the builder uses the
default instance. This implementation stores the passed in BeanHelper
object in the internal parameters map, but
uses a reserved key, so that it is not used for the initialization of properties of the managed configuration object.
The fetchBeanHelper()
method can be used to obtain the BeanHelper
instance from a parameters map.setBeanHelper
in interface BasicBuilderProperties<BasicBuilderParameters>
beanHelper
- the BeanHelper
to be used by the builderpublic BasicBuilderParameters setConfigurationDecoder(ConfigurationDecoder decoder)
ConfigurationDecoder
object for this configuration. This object is called when encoded properties
are queried using the getEncodedString()
method. This implementation stores the passed in ConfigurationDecoder
object in the internal parameters
map.setConfigurationDecoder
in interface BasicBuilderProperties<BasicBuilderParameters>
decoder
- the ConfigurationDecoder
to be usedpublic void merge(BuilderParameters p)
p
- the object whose properties should be merged (must not be null)IllegalArgumentException
- if the passed in object is nullpublic void inheritFrom(Map<String,?> source)
ConfigurationInterpolator
- are
tightly connected to a configuration and cannot be reused in a different context. For other properties, e.g. a file
name, it does not make sense to copy it. Therefore, an implementation has to be explicit in the properties it wants
to take over.source
- the source properties to inherit fromIllegalArgumentException
- if the source map is nullpublic static InterpolatorSpecification fetchInterpolatorSpecification(Map<String,Object> params)
ConfigurationInterpolator
from the specified map with parameters. All
properties related to interpolation are evaluated and added to the specification object.params
- the map with parameters (must not be null)InterpolatorSpecification
object constructed with data from the mapIllegalArgumentException
- if the map is null or contains invalid datapublic static BeanHelper fetchBeanHelper(Map<String,Object> params)
BeanHelper
object from the specified map with parameters. This method can be used to obtain an
instance from a parameters map that has been set via the setBeanHelper()
method. If no such instance is
found, result is null.params
- the map with parameters (must not be null)BeanHelper
stored in this map or nullIllegalArgumentException
- if the map is nullpublic BasicBuilderParameters clone()
ConfigurationInterpolator
or
Lookup
s are shared between this and the newly created instance.protected void storeProperty(String key, Object value)
key
- the key of the propertyvalue
- the value of the propertyprotected Object fetchProperty(String key)
key
- the key of the property in questionprotected void copyPropertiesFrom(Map<String,?> source, String... keys)
source
- the source mapkeys
- the keys to be copiedCopyright © 2001–2022 The Apache Software Foundation. All rights reserved.