Class AbstractXmlBasedProvider<T_ID,​T_OBJECT extends Identifiable<T_ID>>

  • Type Parameters:
    T_ID - the key type, e.g. ThingTypeUID, ChannelUID, URI,...
    T_OBJECT - the object type, e.g. ThingType, ChannelType, ConfigDescription,...
    Direct Known Subclasses:
    AbstractXmlConfigDescriptionProvider

    public abstract class AbstractXmlBasedProvider<T_ID,​T_OBJECT extends Identifiable<T_ID>>
    extends Object
    Common base class for XML based providers.
    Author:
    Simon Kaufmann - Initial contribution, factored out of subclasses
    • Constructor Detail

      • AbstractXmlBasedProvider

        public AbstractXmlBasedProvider()
    • Method Detail

      • localize

        protected abstract @Nullable T_OBJECT localize​(org.osgi.framework.Bundle bundle,
                                                       T_OBJECT object,
                                                       @Nullable Locale locale)
        Create a translated/localized copy of the given object.
        Parameters:
        bundle - the module to be used for the look-up of the translations
        object - the object to translate
        locale - the target locale
        Returns:
        a translated copy of the given object or null if translation was not possible.
      • add

        public final void add​(org.osgi.framework.Bundle bundle,
                              T_OBJECT object)
        Adds an object to the internal list associated with the specified module.

        This method returns silently, if any of the parameters is null.

        Parameters:
        bundle - the module to which the object is to be added
        object - the object to be added
      • addAll

        public final void addAll​(org.osgi.framework.Bundle bundle,
                                 Collection<T_OBJECT> objectList)
        Adds a Collection of objects to the internal list associated with the specified module.

        This method returns silently, if any of the parameters is null.

        Parameters:
        bundle - the module to which the object is to be added
        objectList - the objects to be added
      • get

        protected final @Nullable T_OBJECT get​(T_ID key,
                                               @Nullable Locale locale)
        Gets the object with the given key.
        Parameters:
        key - the key which identifies the object
        locale - the locale
        Returns:
        the object if found, null otherwise
      • getAll

        protected final Collection<T_OBJECT> getAll​(@Nullable Locale locale)
        Gets all available objects.
        Parameters:
        locale - the locale
        Returns:
        a collection containing all available objects. Never null
      • removeAll

        public final void removeAll​(org.osgi.framework.Bundle bundle)
        Removes all objects from the internal list associated with the specified module.

        This method returns silently if the module is null.

        Parameters:
        bundle - the module for which all associated Thing types to be removed