Interface Registry<E extends Identifiable<K>,K>

Type Parameters:
E - type of the elements in the registry
All Known Subinterfaces:
ItemRegistry, ItemUIRegistry, MetadataRegistry, ModuleTypeRegistry, PersistenceServiceConfigurationRegistry, RuleRegistry, SemanticTagRegistry, TemplateRegistry<E>, ThingRegistry, TransformationRegistry, UIComponentRegistry, UserRegistry
All Known Implementing Classes:
AbstractLinkRegistry, AbstractRegistry, ItemChannelLinkRegistry, RuleSupportRuleRegistryDelegate

@NonNullByDefault public interface Registry<@NonNull E extends Identifiable<@NonNull K>,@NonNull K>
The Registry interface represents a registry for elements of the type E. The concrete sub interfaces are registered as OSGi services.
Author:
Dennis Nobel - Initial contribution, Victor Toni - provide elements as Stream, Kai Kreuzer - added null annotations
  • Method Details

    • addRegistryChangeListener

      void addRegistryChangeListener(RegistryChangeListener<@NonNull E> listener)
      Adds a RegistryChangeListener to the registry.
      Parameters:
      listener - registry change listener
    • getAll

      Collection<E> getAll()
      Returns a collection of all elements in the registry.
      Returns:
      collection of all elements in the registry
    • stream

      Stream<E> stream()
      Returns a stream of all elements in the registry.
      Returns:
      stream of all elements in the registry
    • get

      @Nullable E get(@NonNull K key)
      This method retrieves a single element from the registry.
      Parameters:
      key - key of the element
      Returns:
      element or null if no element was found
    • removeRegistryChangeListener

      void removeRegistryChangeListener(RegistryChangeListener<@NonNull E> listener)
      Removes a RegistryChangeListener from the registry.
      Parameters:
      listener - registry change listener
    • add

      E add(@NonNull E element)
      Adds the given element to the according ManagedProvider.
      Parameters:
      element - element to be added (must not be null)
      Returns:
      the added element or newly created object of the same type
      Throws:
      IllegalStateException - if no ManagedProvider is available
    • update

      @Nullable E update(@NonNull E element)
      Updates the given element at the according ManagedProvider.
      Parameters:
      element - element to be updated (must not be null)
      Returns:
      returns the old element or null if no element with the same key exists
      Throws:
      IllegalStateException - if no ManagedProvider is available
    • remove

      @Nullable E remove(@NonNull K key)
      Removes the given element from the according ManagedProvider.
      Parameters:
      key - key of the element (must not be null)
      Returns:
      element that was removed, or null if no element with the given key exists
      Throws:
      IllegalStateException - if no ManagedProvider is available