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>

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
  • Constructor Details

  • Method Details

    • fromParameters

      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

      Gets the pattern for determining file names for managed configurations.
      Returns:
      the file pattern
    • setFilePattern

      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

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

      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

      Gets 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

      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 Lookups 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