org.apache.commons.configuration2.builder.combined

## 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 a `MultiFileConfigurationBuilder` 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
  Version:
    $Id: MultiFileBuilderParametersImpl.java 1679775 2015-05-16 17:42:45Z oheger $

- - ### Field Summary

    - ### Fields inherited from interface org.apache.commons.configuration2.builder.BuilderParameters

      `RESERVED_PARAMETER_PREFIX`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MultiFileBuilderParametersImpl()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `MultiFileBuilderParametersImpl` | `clone()` Clones this object.
    `static MultiFileBuilderParametersImpl` | `fromParameters(Map<String,Object> params)` Obtains an instance of this class from the given map with parameters.
    `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.
    `String` | `getFilePattern()` Returns the pattern for determining file names for managed configurations.
    `BuilderParameters` | `getManagedBuilderParameters()` Returns the parameters object for managed configuration builders.
    `Map<String,Object>` | `getParameters()` Returns a map with all parameters defined by this objects.
    `MultiFileBuilderParametersImpl` | `setFilePattern(String p)` Sets the pattern string.
    `MultiFileBuilderParametersImpl` | `setManagedBuilderParameters(BuilderParameters p)` Sets a parameters object to be used when creating a managed configuration.

    - ### Methods inherited from class org.apache.commons.configuration2.builder.BasicBuilderParameters

      `fetchBeanHelper, fetchInterpolatorSpecification, fetchProperty, merge, setBeanHelper, setConfigurationDecoder, setConversionHandler, setDefaultLookups, setInterpolator, setListDelimiterHandler, setLogger, setParentInterpolator, setPrefixLookups, setSynchronizer, setThrowExceptionOnMissing, storeProperty`

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

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

- - ### Constructor Detail

    - #### MultiFileBuilderParametersImpl

          public MultiFileBuilderParametersImpl()

  - ### Method Detail

    - #### fromParameters

          public static MultiFileBuilderParametersImpl fromParameters(Map<String,Object> params)

      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 to `fromParameters(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 the `getParameters()` method. If the map does not contain an instance under the expected key and the `createIfMissing` 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

    - #### getFilePattern

          public String getFilePattern()

      Returns the pattern for determining file names for managed configurations.
      Returns:
        the file pattern

    - #### setFilePattern

          public MultiFileBuilderParametersImpl setFilePattern(String p)

      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 interface `MultiFileBuilderProperties<MultiFileBuilderParametersImpl>`
      Parameters:
        `p` - the pattern string
      Returns:
        a reference to this object for method chaining

    - #### getManagedBuilderParameters

          public BuilderParameters getManagedBuilderParameters()

      Returns the parameters object for managed configuration builders.
      Returns:
        the parameters for sub configurations

    - #### setManagedBuilderParameters

          public MultiFileBuilderParametersImpl setManagedBuilderParameters(BuilderParameters p)

      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 interface `MultiFileBuilderProperties<MultiFileBuilderParametersImpl>`
      Parameters:
        `p` - the parameters object for a sub configuration
      Returns:
        a reference to this object for method chaining

    - #### getParameters

          public Map<String,Object> getParameters()

      Returns a map with all parameters defined by this objects. The keys of the map correspond to concrete properties supported by the `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. This implementation puts a reference to this object under a reserved key in the resulting parameters map.
      Specified by:
        `getParameters` in interface `BuilderParameters`
      Overrides:
        `getParameters` in class `BasicBuilderParameters`
      Returns:
        a map with builder parameters

    - #### clone

          public MultiFileBuilderParametersImpl 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 a `ConfigurationInterpolator` or `Lookup`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 class `BasicBuilderParameters`
      Returns:
        a clone of this object

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