org.apache.commons.configuration2.builder

## Class BuilderConfigurationWrapperFactory

- java.lang.Object
- - org.apache.commons.configuration2.builder.BuilderConfigurationWrapperFactory

-     public class BuilderConfigurationWrapperFactory
      extends Object

  A class that allows the creation of configuration objects wrapping a `ConfigurationBuilder`.

  Using this class special `Configuration` proxies can be created that delegate all method invocations to another `Configuration` 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 `Configuration` 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 1624601 2014-09-12 18:04:36Z oheger $

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `BuilderConfigurationWrapperFactory.EventSourceSupport` An enumeration class with different options for supporting the `EventSource` interface in generated `Configuration` proxies.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BuilderConfigurationWrapperFactory()` Creates a new instance of `BuilderConfigurationWrapperFactory` setting the default `EventSourceSupport` NONE.
    `BuilderConfigurationWrapperFactory(BuilderConfigurationWrapperFactory.EventSourceSupport evSrcSupport)` Creates a new instance of `BuilderConfigurationWrapperFactory` and sets the property for supporting the `EventSource` interface.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T extends Configuration> T` | `createBuilderConfigurationWrapper(Class<T> ifcClass, ConfigurationBuilder<? extends T> builder)` Creates a wrapper `Configuration` on top of the specified `ConfigurationBuilder`.
    `static <T extends Configuration> T` | `createBuilderConfigurationWrapper(Class<T> ifcClass, ConfigurationBuilder<? extends T> builder, BuilderConfigurationWrapperFactory.EventSourceSupport evSrcSupport)` Returns a `Configuration` object which wraps the specified `ConfigurationBuilder`.
    `BuilderConfigurationWrapperFactory.EventSourceSupport` | `getEventSourceSupport()` Returns the level of `EventSource` support used when generating `Configuration` objects.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### BuilderConfigurationWrapperFactory

          public BuilderConfigurationWrapperFactory(BuilderConfigurationWrapperFactory.EventSourceSupport evSrcSupport)

      Creates a new instance of `BuilderConfigurationWrapperFactory` and sets the property for supporting the `EventSource` interface.
      Parameters:
        `evSrcSupport` - the level of `EventSource` support

    - #### BuilderConfigurationWrapperFactory

          public BuilderConfigurationWrapperFactory()

      Creates a new instance of `BuilderConfigurationWrapperFactory` setting the default `EventSourceSupport` NONE.

  - ### Method Detail

    - #### createBuilderConfigurationWrapper

          public <T extends Configuration> T createBuilderConfigurationWrapper(Class<T> ifcClass,
                                                                      ConfigurationBuilder<? extends T> builder)

      Creates a wrapper `Configuration` on top of the specified `ConfigurationBuilder`. This implementation delegates to `createBuilderConfigurationWrapper(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 null
        `builder` - the wrapped `ConfigurationBuilder` (must not be null)
      Throws:
        `IllegalArgumentException` - if a required parameter is missing
        `ConfigurationRuntimeException` - if an error occurs when creating the result `Configuration`

    - #### getEventSourceSupport

          public BuilderConfigurationWrapperFactory.EventSourceSupport getEventSourceSupport()

      Returns the level of `EventSource` support used when generating `Configuration` objects.
      Returns:
        the level of `EventSource` support

    - #### createBuilderConfigurationWrapper

          public static <T extends Configuration> T createBuilderConfigurationWrapper(Class<T> ifcClass,
                                                                      ConfigurationBuilder<? extends T> builder,
                                                                      BuilderConfigurationWrapperFactory.EventSourceSupport evSrcSupport)

      Returns a `Configuration` object which wraps the specified `ConfigurationBuilder`. Each access of the configuration is delegated to a corresponding call on the `Configuration` 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 null
        `builder` - the wrapped `ConfigurationBuilder` (must not be null)
        `evSrcSupport` - the level of `EventSource` support
      Throws:
        `IllegalArgumentException` - if a required parameter is missing
        `ConfigurationRuntimeException` - if an error occurs when creating the result `Configuration`

Copyright © 2001–2014 The Apache Software Foundation. All rights reserved.