Package org.openhab.core.config.core.xml
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
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
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 aCollection
of objects to the internal list associated with the specified module.protected final @Nullable T_OBJECT
Gets the object with the given key.protected final Collection<T_OBJECT>
Gets all available objects.protected abstract @Nullable T_OBJECT
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.
-
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 translationsobject
- the object to translatelocale
- the target locale- Returns:
- a translated copy of the given object or
null
if translation was not possible.
-
add
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 addedobject
- the object to be added
-
addAll
public final void addAll(org.osgi.framework.Bundle bundle, Collection<@NonNull T_OBJECT> objectList) Adds aCollection
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 addedobjectList
- the objects to be added
-
get
Gets the object with the given key.- Parameters:
key
- the key which identifies the objectlocale
- the locale- Returns:
- the object if found,
null
otherwise
-
getAll
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
-