Class InterpolatorSpecification.Builder
java.lang.Object
org.apache.commons.configuration2.interpol.InterpolatorSpecification.Builder
- Enclosing class:
InterpolatorSpecification
A builder class for creating instances of InterpolatorSpecification.
This class provides a fluent API for defining the various properties of an InterpolatorSpecification object.
Note: This builder class is not thread-safe.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreate()Creates a newInterpolatorSpecificationinstance with the properties set so far.voidreset()Removes all data from this builder.withDefaultLookup(Lookup lookup) Adds the givenLookupobject to the list of default lookups.withDefaultLookups(Collection<? extends Lookup> lookups) Adds the content of the given collection to the default lookups managed by this builder.Sets theConfigurationInterpolatorinstance for theInterpolatorSpecification.Sets an optional parentConfigurationInterpolator.withPrefixLookup(String prefix, Lookup lookup) Adds aLookupobject for a given prefix.withPrefixLookups(Map<String, ? extends Lookup> lookups) Adds the content of the given map to the prefix lookups managed by this builder.Sets the function used to convert interpolated values to strings.
-
Constructor Details
-
Builder
public Builder()Constructs a new instance.
-
-
Method Details
-
create
Creates a newInterpolatorSpecificationinstance with the properties set so far. After that this builder instance is reset so that it can be reused for creating further specification objects.- Returns:
- the newly created
InterpolatorSpecification
-
reset
Removes all data from this builder. Afterwards it can be used to define a brand newInterpolatorSpecificationobject. -
withDefaultLookup
Adds the givenLookupobject to the list of default lookups.- Parameters:
lookup- theLookup(must not be null)- Returns:
- a reference to this builder for method chaining
- Throws:
IllegalArgumentException- if theLookupis null
-
withDefaultLookups
Adds the content of the given collection to the default lookups managed by this builder. The collection can be null, then this method has no effect.- Parameters:
lookups- the collection with lookups to be added- Returns:
- a reference to this builder for method chaining
- Throws:
IllegalArgumentException- if the collection contains null entries
-
withInterpolator
Sets theConfigurationInterpolatorinstance for theInterpolatorSpecification. This means that aConfigurationInterpolatorhas been created and set up externally and can be used directly.- Parameters:
ci- theConfigurationInterpolator(can be null)- Returns:
- a reference to this builder for method chaining
-
withParentInterpolator
Sets an optional parentConfigurationInterpolator. If defined, this object is set as parent of a newly createdConfigurationInterpolatorinstance.- Parameters:
parent- the parentConfigurationInterpolator(can be null)- Returns:
- a reference to this builder for method chaining
-
withPrefixLookup
Adds aLookupobject for a given prefix.- Parameters:
prefix- the prefix (must not be null)lookup- theLookup(must not be null)- Returns:
- a reference to this builder for method chaining
- Throws:
IllegalArgumentException- if a required parameter is missing
-
withPrefixLookups
Adds the content of the given map to the prefix lookups managed by this builder. The map can be null, then this method has no effect.- Parameters:
lookups- the map with prefix lookups to be added- Returns:
- a reference to this builder for method chaining
- Throws:
IllegalArgumentException- if the map contains null values
-
withStringConverter
Sets the function used to convert interpolated values to strings. Passnullif the default conversion function is to be used.- Parameters:
fn- function used to convert interpolated values to string ornullif the default conversion function is to be used- Returns:
- a reference to this builder for method chaining
-