Class BuilderConfigurationWrapperFactory
- java.lang.Object
-
- org.apache.commons.configuration2.builder.BuilderConfigurationWrapperFactory
-
public class BuilderConfigurationWrapperFactory extends java.lang.Object
A class that allows the creation of configuration objects wrapping a
ConfigurationBuilder
.Using this class special
ImmutableConfiguration
proxies can be created that delegate all method invocations to anotherImmutableConfiguration
obtained from aConfigurationBuilder
. For instance, if there is a configurationc
wrapping the builderbuilder
, the callc.getString(myKey)
is transformed tobuilder.getConfiguration().getString(myKey)
.There are multiple use cases for such a constellation. One example is that client code can continue working with
ImmutableConfiguration
objects while under the hood builders are used. Another example is that dynamic configurations can be realized in a transparent way: a client holds a single configuration (proxy) object, but the underlying builder may return a different data object on each call.- Since:
- 2.0
- Version:
- $Id: BuilderConfigurationWrapperFactory.java 1706911 2015-10-05 20:01:32Z oheger $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BuilderConfigurationWrapperFactory.EventSourceSupport
An enumeration class with different options for supporting theEventSource
interface in generatedImmutableConfiguration
proxies.
-
Constructor Summary
Constructors Constructor Description BuilderConfigurationWrapperFactory()
Creates a new instance ofBuilderConfigurationWrapperFactory
setting the defaultEventSourceSupport
NONE.BuilderConfigurationWrapperFactory(BuilderConfigurationWrapperFactory.EventSourceSupport evSrcSupport)
Creates a new instance ofBuilderConfigurationWrapperFactory
and sets the property for supporting theEventSource
interface.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends ImmutableConfiguration>
TcreateBuilderConfigurationWrapper(java.lang.Class<T> ifcClass, ConfigurationBuilder<? extends T> builder)
Creates a wrapperImmutableConfiguration
on top of the specifiedConfigurationBuilder
.static <T extends ImmutableConfiguration>
TcreateBuilderConfigurationWrapper(java.lang.Class<T> ifcClass, ConfigurationBuilder<? extends T> builder, BuilderConfigurationWrapperFactory.EventSourceSupport evSrcSupport)
Returns aImmutableConfiguration
object which wraps the specifiedConfigurationBuilder
.BuilderConfigurationWrapperFactory.EventSourceSupport
getEventSourceSupport()
Returns the level ofEventSource
support used when generatingImmutableConfiguration
objects.
-
-
-
Constructor Detail
-
BuilderConfigurationWrapperFactory
public BuilderConfigurationWrapperFactory(BuilderConfigurationWrapperFactory.EventSourceSupport evSrcSupport)
Creates a new instance ofBuilderConfigurationWrapperFactory
and sets the property for supporting theEventSource
interface.- Parameters:
evSrcSupport
- the level ofEventSource
support
-
BuilderConfigurationWrapperFactory
public BuilderConfigurationWrapperFactory()
Creates a new instance ofBuilderConfigurationWrapperFactory
setting the defaultEventSourceSupport
NONE.
-
-
Method Detail
-
createBuilderConfigurationWrapper
public <T extends ImmutableConfiguration> T createBuilderConfigurationWrapper(java.lang.Class<T> ifcClass, ConfigurationBuilder<? extends T> builder)
Creates a wrapperImmutableConfiguration
on top of the specifiedConfigurationBuilder
. This implementation delegates tocreateBuilderConfigurationWrapper(Class, ConfigurationBuilder, EventSourceSupport)
.- Type Parameters:
T
- the type of the configuration objects returned by this method- Parameters:
ifcClass
- the class of the configuration objects returned by this method; this must be an interface class and must not be nullbuilder
- the wrappedConfigurationBuilder
(must not be null)- Returns:
- the wrapper configuration
- Throws:
java.lang.IllegalArgumentException
- if a required parameter is missingConfigurationRuntimeException
- if an error occurs when creating the resultImmutableConfiguration
-
getEventSourceSupport
public BuilderConfigurationWrapperFactory.EventSourceSupport getEventSourceSupport()
Returns the level ofEventSource
support used when generatingImmutableConfiguration
objects.- Returns:
- the level of
EventSource
support
-
createBuilderConfigurationWrapper
public static <T extends ImmutableConfiguration> T createBuilderConfigurationWrapper(java.lang.Class<T> ifcClass, ConfigurationBuilder<? extends T> builder, BuilderConfigurationWrapperFactory.EventSourceSupport evSrcSupport)
Returns aImmutableConfiguration
object which wraps the specifiedConfigurationBuilder
. Each access of the configuration is delegated to a corresponding call on theImmutableConfiguration
object managed by the builder. This is a convenience method which allows creating wrapper configurations without having to instantiate this class.- Type Parameters:
T
- the type of the configuration objects returned by this method- Parameters:
ifcClass
- the class of the configuration objects returned by this method; this must be an interface class and must not be nullbuilder
- the wrappedConfigurationBuilder
(must not be null)evSrcSupport
- the level ofEventSource
support- Returns:
- the wrapper configuration
- Throws:
java.lang.IllegalArgumentException
- if a required parameter is missingConfigurationRuntimeException
- if an error occurs when creating the resultImmutableConfiguration
-
-