Class AbstractXmlBasedProvider<T_ID,T_OBJECT extends Identifiable<@NonNull T_ID>>

java.lang.Object
org.openhab.core.config.core.xml.AbstractXmlBasedProvider<T_ID,T_OBJECT>
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

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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    add(org.osgi.framework.Bundle bundle, @NonNull T_OBJECT object)
    Adds an object to the internal list associated with the specified module.
    final void
    addAll(org.osgi.framework.Bundle bundle, Collection<@NonNull T_OBJECT> objectList)
    Adds a Collection of objects to the internal list associated with the specified module.
    protected final @Nullable T_OBJECT
    get(@NonNull T_ID key, @Nullable Locale locale)
    Gets the object with the given key.
    protected final Collection<T_OBJECT>
    getAll(@Nullable Locale locale)
    Gets all available objects.
    protected abstract @Nullable T_OBJECT
    localize(org.osgi.framework.Bundle bundle, @NonNull T_OBJECT object, @Nullable Locale locale)
    Create a translated/localized copy of the given object.
    final void
    removeAll(org.osgi.framework.Bundle bundle)
    Removes all objects from the internal list associated with the specified module.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractXmlBasedProvider

      public AbstractXmlBasedProvider()
  • Method Details

    • localize

      protected abstract @Nullable T_OBJECT localize(org.osgi.framework.Bundle bundle, @NonNull 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, @NonNull 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<@NonNull 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(@NonNull 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