Class FileBasedBuilderParametersImpl

    • Field Detail

      • PARAM_KEY

        private static final java.lang.String PARAM_KEY
        Constant for the key in the parameters map used by this class.
        See Also:
        Constant Field Values
      • PROP_REFRESH_DELAY

        private static final java.lang.String PROP_REFRESH_DELAY
        Property name for the reloading refresh delay.
        See Also:
        Constant Field Values
      • PROP_DETECTOR_FACTORY

        private static final java.lang.String PROP_DETECTOR_FACTORY
        Property name of the reloading detector factory.
        See Also:
        Constant Field Values
      • fileHandler

        private FileHandler fileHandler
        Stores the associated file handler for the location of the configuration.
      • reloadingDetectorFactory

        private ReloadingDetectorFactory reloadingDetectorFactory
        The factory for reloading detectors.
      • reloadingRefreshDelay

        private java.lang.Long reloadingRefreshDelay
        The refresh delay for reloading support.
    • Constructor Detail

      • FileBasedBuilderParametersImpl

        public FileBasedBuilderParametersImpl()
        Creates a new instance of FileBasedBuilderParametersImpl with an uninitialized FileHandler object.
      • FileBasedBuilderParametersImpl

        public FileBasedBuilderParametersImpl​(FileHandler handler)
        Creates a new instance of FileBasedBuilderParametersImpl and associates it with the given FileHandler object. If the handler is null, a new handler instance is created.
        Parameters:
        handler - the associated FileHandler (can be null)
    • Method Detail

      • fromMap

        public static FileBasedBuilderParametersImpl fromMap​(java.util.Map<java.lang.String,​?> map)
        Creates a new FileBasedBuilderParametersImpl object from the content of the given map. While fromParameters() expects that an object already exists and is stored in the given map, this method creates a new instance based on the content of the map. The map can contain properties of a FileHandler and some additional settings which are stored directly in the newly created object. If the map is null, an uninitialized instance is returned.
        Parameters:
        map - the map with properties (must not be null)
        Returns:
        the newly created instance
        Throws:
        java.lang.ClassCastException - if the map contains invalid data
      • fromParameters

        public static FileBasedBuilderParametersImpl fromParameters​(java.util.Map<java.lang.String,​?> params)
        Looks up an instance of this class in the specified parameters map. This is equivalent to fromParameters(params, false;}
        Parameters:
        params - the map with parameters (must not be null
        Returns:
        the instance obtained from the map or null
        Throws:
        java.lang.IllegalArgumentException - if the map is null
      • fromParameters

        public static FileBasedBuilderParametersImpl fromParameters​(java.util.Map<java.lang.String,​?> params,
                                                                    boolean createIfMissing)
        Looks up an instance of this class in the specified parameters map and optionally creates a new one if none is found. This method can be used to obtain an instance of this class which has been stored in a parameters map. It is compatible with the getParameters() method.
        Parameters:
        params - the map with parameters (must not be null
        createIfMissing - determines the behavior if no instance is found in the map; if true, a new instance with default settings is created; if false, null is returned
        Returns:
        the instance obtained from the map or null
        Throws:
        java.lang.IllegalArgumentException - if the map is null
      • clone

        public FileBasedBuilderParametersImpl 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 creates a copy of the FileHandler.
        Overrides:
        clone in class BasicBuilderParameters
        Returns:
        a clone of this object
      • getFileHandler

        public FileHandler getFileHandler()
        Gets the FileHandler managed by this object. This object is updated every time the file location is changed.
        Returns:
        the managed FileHandler
      • 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. This implementation returns a map which contains this object itself under a specific key. The static fromParameters() method can be used to extract an instance from a parameters map. Of course, the properties inherited from the base class are also added to the result map.
        Specified by:
        getParameters in interface BuilderParameters
        Overrides:
        getParameters in class BasicBuilderParameters
        Returns:
        a map with builder parameters
      • getReloadingDetectorFactory

        public ReloadingDetectorFactory getReloadingDetectorFactory()
        Gets the ReloadingDetectorFactory. Result may be null which means that the default factory is to be used.
        Returns:
        the ReloadingDetectorFactory
      • getReloadingRefreshDelay

        public java.lang.Long getReloadingRefreshDelay()
        Gets the refresh delay for reload operations. Result may be null if this value has not been set.
        Returns:
        the reloading refresh delay
      • 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. This implementation takes some properties defined in this class into account.
        Overrides:
        inheritFrom in class BasicBuilderParameters
        Parameters:
        source - the source properties to inherit from