Class AbstractGenericBindingProvider

  • All Implemented Interfaces:
    BindingProvider, BindingConfigReader

    public abstract class AbstractGenericBindingProvider
    extends Object
    implements BindingConfigReader, BindingProvider

    This abstract class serves as a basis for implementations of binding providers that retrieve binding information from the items configuration file(s), i.e. they register as BindingConfigReaders.

    This class takes care of tracking all changes in the binding config strings and makes sure that all listeners are correctly notified of any change.

    Author:
    Kai Kreuzer - Initial contribution
    • Field Detail

      • contextMap

        protected Map<String,​Set<Item>> contextMap
        stores information about the context of items. The map has this content structure: context -> Set of Items
    • Constructor Detail

      • AbstractGenericBindingProvider

        public AbstractGenericBindingProvider()
    • Method Detail

      • addBindingChangeListener

        public void addBindingChangeListener​(BindingChangeListener listener)
        Description copied from interface: BindingProvider
        Adds a binding change listener, which gets notified whenever there are changes in the binding configuration
        Specified by:
        addBindingChangeListener in interface BindingProvider
        Parameters:
        listener - the binding change listener to add
      • processBindingConfiguration

        public void processBindingConfiguration​(String context,
                                                Item item,
                                                String bindingConfig)
                                         throws BindingConfigParseException
        Description copied from interface: BindingConfigReader
        This method is called by the GenericItemProvider whenever it comes across a binding configuration string for an item.
        Specified by:
        processBindingConfiguration in interface BindingConfigReader
        Parameters:
        context - a string of the context from where this item comes from. Usually the file name of the config file
        item - the item for which the binding is defined
        bindingConfig - the configuration string that must be processed
        Throws:
        BindingConfigParseException - if the configuration string is not valid
      • removeConfigurations

        public void removeConfigurations​(String context)
        Description copied from interface: BindingConfigReader
        Removes all configuration information for a given context. This is usually called if a config file is reloaded, so that the old values are removed, before the new ones are processed.
        Specified by:
        removeConfigurations in interface BindingConfigReader
        Parameters:
        context - the context of the configurations that should be removed
      • addBindingConfig

        protected void addBindingConfig​(Item item,
                                        BindingConfig config)
      • providesBindingFor

        public boolean providesBindingFor​(String itemName)
        Description copied from interface: BindingProvider
        Indicates whether this binding provider contains a binding for the given itemName
        Specified by:
        providesBindingFor in interface BindingProvider
        Parameters:
        itemName - the itemName to check
        Returns:
        true if this provider contains an adequate mapping for itemName and false otherwise.
      • providesBinding

        public boolean providesBinding()
        Description copied from interface: BindingProvider
        Indicates whether this binding provider contains any binding
        Specified by:
        providesBinding in interface BindingProvider
        Returns:
        true if this provider contains any binding configuration and false otherwise