Class BuilderConfigurationWrapperFactory
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 another ImmutableConfiguration obtained from a ConfigurationBuilder. For instance, if there is a
configuration c wrapping the builder builder, the call c.getString(myKey) is transformed to
builder.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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumAn enumeration class with different options for supporting theEventSourceinterface in generatedImmutableConfigurationproxies. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance ofBuilderConfigurationWrapperFactorysetting the defaultEventSourceSupportNONE.BuilderConfigurationWrapperFactory(BuilderConfigurationWrapperFactory.EventSourceSupport evSrcSupport) Creates a new instance ofBuilderConfigurationWrapperFactoryand sets the property for supporting theEventSourceinterface. -
Method Summary
Modifier and TypeMethodDescription<T extends ImmutableConfiguration>
TcreateBuilderConfigurationWrapper(Class<T> ifcClass, ConfigurationBuilder<? extends T> builder) Creates a wrapperImmutableConfigurationon top of the specifiedConfigurationBuilder.static <T extends ImmutableConfiguration>
TcreateBuilderConfigurationWrapper(Class<T> ifcClass, ConfigurationBuilder<? extends T> builder, BuilderConfigurationWrapperFactory.EventSourceSupport evSrcSupport) Creates aImmutableConfigurationobject which wraps the specifiedConfigurationBuilder.Gets the level ofEventSourcesupport used when generatingImmutableConfigurationobjects.
-
Constructor Details
-
BuilderConfigurationWrapperFactory
public BuilderConfigurationWrapperFactory()Creates a new instance ofBuilderConfigurationWrapperFactorysetting the defaultEventSourceSupportNONE. -
BuilderConfigurationWrapperFactory
public BuilderConfigurationWrapperFactory(BuilderConfigurationWrapperFactory.EventSourceSupport evSrcSupport) Creates a new instance ofBuilderConfigurationWrapperFactoryand sets the property for supporting theEventSourceinterface.- Parameters:
evSrcSupport- the level ofEventSourcesupport
-
-
Method Details
-
createBuilderConfigurationWrapper
public static <T extends ImmutableConfiguration> T createBuilderConfigurationWrapper(Class<T> ifcClass, ConfigurationBuilder<? extends T> builder, BuilderConfigurationWrapperFactory.EventSourceSupport evSrcSupport) Creates aImmutableConfigurationobject which wraps the specifiedConfigurationBuilder. Each access of the configuration is delegated to a corresponding call on theImmutableConfigurationobject 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 ofEventSourcesupport- Returns:
- the wrapper configuration
- Throws:
IllegalArgumentException- if a required parameter is missingConfigurationRuntimeException- if an error occurs when creating the resultImmutableConfiguration
-
createBuilderConfigurationWrapper
public <T extends ImmutableConfiguration> T createBuilderConfigurationWrapper(Class<T> ifcClass, ConfigurationBuilder<? extends T> builder) Creates a wrapperImmutableConfigurationon 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:
IllegalArgumentException- if a required parameter is missingConfigurationRuntimeException- if an error occurs when creating the resultImmutableConfiguration
-
getEventSourceSupport
Gets the level ofEventSourcesupport used when generatingImmutableConfigurationobjects.- Returns:
- the level of
EventSourcesupport
-