Class InterpolatorSpecification

java.lang.Object
org.apache.commons.configuration2.interpol.InterpolatorSpecification

public final class InterpolatorSpecification extends Object

A simple value class defining a ConfigurationInterpolator.

Objects of this class can be used for creating new ConfigurationInterpolator instances; they contain all required properties. It is either possible to set a fully initialized ConfigurationInterpolator directly which can be used as is. Alternatively, some or all properties of an instance to be newly created can be set. These properties include

  • a map with Lookup objects associated with a specific prefix
  • a collection with default Lookup objects (without a prefix)
  • a parent ConfigurationInterpolator
  • a function used to convert interpolated values into strings

When setting up a configuration it is possible to define the ConfigurationInterpolator in terms of this class. The configuration will then either use the ConfigurationInterpolator instance explicitly defined in the InterpolatorSpecification instance or create a new one.

Instances are not created directly, but using the nested Builder class. They are then immutable.

Since:
2.0
  • Field Details

    • interpolator

      private final ConfigurationInterpolator interpolator
      The ConfigurationInterpolator instance to be used directly.
    • parentInterpolator

      private final ConfigurationInterpolator parentInterpolator
      The parent ConfigurationInterpolator.
    • prefixLookups

      private final Map<String,Lookup> prefixLookups
      The map with prefix lookups.
    • defaultLookups

      private final Collection<Lookup> defaultLookups
      The collection with default lookups.
    • stringConverter

      private final Function<Object,String> stringConverter
      Function used to convert interpolated values to strings.
  • Constructor Details

    • InterpolatorSpecification

      private InterpolatorSpecification(InterpolatorSpecification.Builder builder)
      Creates a new instance of InterpolatorSpecification with the properties defined by the given builder object.
      Parameters:
      builder - the builder
  • Method Details

    • getDefaultLookups

      public Collection<Lookup> getDefaultLookups()
      Gets a collection with the default lookups.
      Returns:
      the default lookups for a new ConfigurationInterpolator instance (never null)
    • getInterpolator

      public ConfigurationInterpolator getInterpolator()
      Gets the ConfigurationInterpolator instance to be used directly.
      Returns:
      the ConfigurationInterpolator (can be null)
    • getParentInterpolator

      public ConfigurationInterpolator getParentInterpolator()
      Gets the parent ConfigurationInterpolator object.
      Returns:
      the parent ConfigurationInterpolator (can be null)
    • getPrefixLookups

      public Map<String,Lookup> getPrefixLookups()
      Gets a map with prefix lookups. The keys of the map are the prefix strings, its values are the corresponding Lookup objects.
      Returns:
      the prefix lookups for a new ConfigurationInterpolator instance (never null)
    • getStringConverter

      public Function<Object,String> getStringConverter()
      Gets the function used to convert interpolated values to strings or null if the default conversion function is to be used.
      Returns:
      function used to convert interpolated values to strings or null if the default conversion function is to be used