Class AbstractLinkRegistry<L extends AbstractLink,P extends Provider<L>>

java.lang.Object
org.openhab.core.common.registry.AbstractRegistry<L,String,P>
org.openhab.core.thing.link.AbstractLinkRegistry<L,P>
Type Parameters:
L - Concrete type of the abstract link
All Implemented Interfaces:
ProviderChangeListener<L>, Registry<L,String>
Direct Known Subclasses:
ItemChannelLinkRegistry

@NonNullByDefault public abstract class AbstractLinkRegistry<L extends AbstractLink,P extends Provider<L>> extends AbstractRegistry<L,String,P>
AbstractLinkRegistry is an abstract class for link based registries, which handle AbstractLinks.
Author:
Dennis Nobel - Initial contribution, Markus Rathgeb - Use separate collections to improve performance
  • Constructor Details

    • AbstractLinkRegistry

      protected AbstractLinkRegistry(Class<P> providerClazz)
  • Method Details

    • onAddElement

      protected void onAddElement(L element)
      Description copied from class: AbstractRegistry
      This method is called before an element is added. The implementing class can override this method to perform initialization logic or check the validity of the element.

      To keep custom logic on the inheritance chain, you must call always the super implementation first.

      If the method throws an IllegalArgumentException the element will not be added.

      Overrides:
      onAddElement in class AbstractRegistry<L extends AbstractLink,String,P extends Provider<L>>
      Parameters:
      element - element to be added
    • onRemoveElement

      protected void onRemoveElement(L element)
      Description copied from class: AbstractRegistry
      This method is called before an element is removed. The implementing class can override this method to perform specific logic.

      To keep custom logic on the inheritance chain, you must call always the super implementation first.

      Overrides:
      onRemoveElement in class AbstractRegistry<L extends AbstractLink,String,P extends Provider<L>>
      Parameters:
      element - element to be removed
    • onUpdateElement

      protected void onUpdateElement(L oldElement, L element)
      Description copied from class: AbstractRegistry
      This method is called before an element is updated. The implementing class can override this method to perform specific logic or check the validity of the updated element.

      To keep custom logic on the inheritance chain, you must call always the super implementation first.

      Overrides:
      onUpdateElement in class AbstractRegistry<L extends AbstractLink,String,P extends Provider<L>>
      Parameters:
      oldElement - old element (before update, as given by the provider)
      element - updated element (after update)

      If the method throws an IllegalArgumentException the element will not be updated.

    • isLinked

      public boolean isLinked(String itemName, UID uid)
      Returns if an item for a given item name is linked to a channel or thing for a given UID.
      Parameters:
      itemName - item name
      uid - UID
      Returns:
      true if linked, false otherwise
    • isLinked

      public boolean isLinked(String itemName)
      Returns if a link for the given item name exists.
      Parameters:
      itemName - item name
      Returns:
      true if a link exists, otherwise false
    • isLinked

      public boolean isLinked(UID uid)
      Returns if a link for the given UID exists.
      Parameters:
      uid - UID
      Returns:
      true if a link exists, otherwise false
    • getLinkedItemNames

      public Set<String> getLinkedItemNames(UID uid)
      Returns the item names, which are bound to the given UID.
      Parameters:
      uid - UID
      Returns:
      a non-null unmodifiable collection of item names that are linked to the given UID.
    • getLinks

      public Set<L> getLinks(UID uid)
      Returns all links for a given UID.
      Parameters:
      uid - a channel UID
      Returns:
      an unmodifiable set of links for the given UID
    • getLinks

      public Set<L> getLinks(String itemName)
      Returns all links for a given item name.
      Parameters:
      itemName - the name of the item
      Returns:
      an unmodifiable set of links for the given item name