Class BasicBuilderParameters

    • Constructor Detail

      • BasicBuilderParameters

        public BasicBuilderParameters()
        Creates a new instance of BasicBuilderParameters.
    • Method Detail

      • getParameters

        public java.util.Map<java.lang.String,​java.lang.Object> 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.
        Specified by:
        getParameters in interface BuilderParameters
        Returns:
        a map with builder parameters
      • setThrowExceptionOnMissing

        public BasicBuilderParameters setThrowExceptionOnMissing​(boolean b)
        Sets the value of the throwExceptionOnMissing property. This property controls the configuration's behavior if missing properties are queried: a value of true causes the configuration to throw an exception, for a value of false it will return null values. (Note: Methods returning a primitive data type will always throw an exception if the property is not defined.)
        Specified by:
        setThrowExceptionOnMissing in interface BasicBuilderProperties<BasicBuilderParameters>
        Parameters:
        b - the value of the property
        Returns:
        a reference to this object for method chaining
      • setInterpolator

        public BasicBuilderParameters setInterpolator​(ConfigurationInterpolator ci)
        Sets the ConfigurationInterpolator to be used for this configuration. Using this method a custom ConfigurationInterpolator can be set which can be freely configured. Alternatively, it is possible to add custom Lookup objects using other methods provided by this interface. The passed in ConfigurationInterpolator is set without modifications.
        Specified by:
        setInterpolator in interface BasicBuilderProperties<BasicBuilderParameters>
        Parameters:
        ci - the ConfigurationInterpolator for this configuration
        Returns:
        a reference to this object for method chaining
      • setSynchronizer

        public BasicBuilderParameters setSynchronizer​(Synchronizer sync)
        Sets the Synchronizer object for this configuration. This object is used to protect this configuration instance against concurrent access. The concrete Synchronizer implementation used determines whether a configuration instance is thread-safe or not. This implementation stores the passed in Synchronizer object in the internal parameters map.
        Specified by:
        setSynchronizer in interface BasicBuilderProperties<BasicBuilderParameters>
        Parameters:
        sync - the Synchronizer to be used (a value of null means that a default Synchronizer is used)
        Returns:
        a reference to this object for method chaining
      • setConversionHandler

        public BasicBuilderParameters setConversionHandler​(ConversionHandler handler)
        Sets the ConversionHandler object for this configuration. This object is responsible for all data type conversions required for accessing configuration properties in a specific target type. If this property is not set, a default ConversionHandler is used. This implementation stores the passed in ConversionHandler object in the internal parameters map.
        Specified by:
        setConversionHandler in interface BasicBuilderProperties<BasicBuilderParameters>
        Parameters:
        handler - the ConversionHandler to be used
        Returns:
        a reference to this object for method chaining
      • setBeanHelper

        public BasicBuilderParameters setBeanHelper​(BeanHelper beanHelper)
        Sets a BeanHelper object to be used by the configuration builder. The BeanHelper is used to create the managed configuration instance dynamically. It is not a property of the configuration as most other properties defined by this interface. By setting an alternative BeanHelper the process of creating configuration instances via reflection can be adapted. (Some specialized configuration builder implementations also use a BeanHelper to create complex helper objects during construction of their result object. CombinedConfigurationBuilder for instance supports a complex configuration definition format which may contain several specialized bean declarations.) If no specific BeanHelper is set, the builder uses the default instance. This implementation stores the passed in BeanHelper object in the internal parameters map, but uses a reserved key, so that it is not used for the initialization of properties of the managed configuration object. The fetchBeanHelper() method can be used to obtain the BeanHelper instance from a parameters map.
        Specified by:
        setBeanHelper in interface BasicBuilderProperties<BasicBuilderParameters>
        Parameters:
        beanHelper - the BeanHelper to be used by the builder
        Returns:
        a reference to this object for method chaining
      • setConfigurationDecoder

        public BasicBuilderParameters setConfigurationDecoder​(ConfigurationDecoder decoder)
        Sets the ConfigurationDecoder object for this configuration. This object is called when encoded properties are queried using the getEncodedString() method. This implementation stores the passed in ConfigurationDecoder object in the internal parameters map.
        Specified by:
        setConfigurationDecoder in interface BasicBuilderProperties<BasicBuilderParameters>
        Parameters:
        decoder - the ConfigurationDecoder to be used
        Returns:
        a reference to this object for method chaining
      • merge

        public void merge​(BuilderParameters p)
        Merges this object with the given parameters object. This method adds all property values defined by the passed in parameters object to the internal storage which are not already in. So properties already defined in this object take precedence. Property names starting with the reserved parameter prefix are ignored.
        Parameters:
        p - the object whose properties should be merged (must not be null)
        Throws:
        java.lang.IllegalArgumentException - if the passed in object is null
      • inheritFrom

        public void inheritFrom​(java.util.Map<java.lang.String,​?> source)
        Inherits properties from the specified map. This can be used for instance to reuse parameters from one builder in another builder - also in parent-child relations in which a parent builder creates child builders. The purpose of this method is to let a concrete implementation decide which properties can be inherited. Because parameters are basically organized as a map it would be possible to simply copy over all properties from the source object. However, this is not appropriate in all cases. For instance, some properties - like a ConfigurationInterpolator - are tightly connected to a configuration and cannot be reused in a different context. For other properties, e.g. a file name, it does not make sense to copy it. Therefore, an implementation has to be explicit in the properties it wants to take over.
        Parameters:
        source - the source properties to inherit from
        Throws:
        java.lang.IllegalArgumentException - if the source map is null
      • fetchInterpolatorSpecification

        public static InterpolatorSpecification fetchInterpolatorSpecification​(java.util.Map<java.lang.String,​java.lang.Object> params)
        Obtains a specification for a ConfigurationInterpolator from the specified map with parameters. All properties related to interpolation are evaluated and added to the specification object.
        Parameters:
        params - the map with parameters (must not be null)
        Returns:
        an InterpolatorSpecification object constructed with data from the map
        Throws:
        java.lang.IllegalArgumentException - if the map is null or contains invalid data
      • fetchBeanHelper

        public static BeanHelper fetchBeanHelper​(java.util.Map<java.lang.String,​java.lang.Object> params)
        Obtains the BeanHelper object from the specified map with parameters. This method can be used to obtain an instance from a parameters map that has been set via the setBeanHelper() method. If no such instance is found, result is null.
        Parameters:
        params - the map with parameters (must not be null)
        Returns:
        the BeanHelper stored in this map or null
        Throws:
        java.lang.IllegalArgumentException - if the map is null
      • clone

        public BasicBuilderParameters 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.
        Overrides:
        clone in class java.lang.Object
        Returns:
        a clone of this object
      • storeProperty

        protected void storeProperty​(java.lang.String key,
                                     java.lang.Object value)
        Sets a property for this parameters object. Properties are stored in an internal map. With this method a new entry can be added to this map. If the value is null, the key is removed from the internal map. This method can be used by sub classes which also store properties in a map.
        Parameters:
        key - the key of the property
        value - the value of the property
      • fetchProperty

        protected java.lang.Object fetchProperty​(java.lang.String key)
        Obtains the value of the specified property from the internal map. This method can be used by derived classes if a specific property is to be accessed. If the given key is not found, result is null.
        Parameters:
        key - the key of the property in question
        Returns:
        the value of the property with this key or null
      • copyPropertiesFrom

        protected void copyPropertiesFrom​(java.util.Map<java.lang.String,​?> source,
                                          java.lang.String... keys)
        Copies a number of properties from the given map into this object. Properties are only copied if they are defined in the source map.
        Parameters:
        source - the source map
        keys - the keys to be copied