Interface NamedConfigurationTree<T extends ConfigurationProperty<VIEWT>,VIEWT,CHANGET extends VIEWT>

Type Parameters:
T - Type of the underlying configuration tree.
VIEWT - Value type of the underlying node.
CHANGET - Type of the object that changes underlying nodes values.
All Superinterfaces:
ConfigurationProperty<NamedListView<VIEWT>>, ConfigurationTree<NamedListView<VIEWT>,NamedListChange<VIEWT,CHANGET>>

public interface NamedConfigurationTree<T extends ConfigurationProperty<VIEWT>,VIEWT,CHANGET extends VIEWT> extends ConfigurationTree<NamedListView<VIEWT>,NamedListChange<VIEWT,CHANGET>>
Configuration tree representing arbitrary set of named underlying configuration tree of the same type.
  • Method Details

    • get

      @Nullable T get(String name)
      Get named configuration by name.
      Parameters:
      name - Name.
    • get

      @Nullable T get(UUID internalId)
      Retrieves a named list element by its internal id.
      Parameters:
      internalId - Internal id.
      Returns:
      Named list element, associated with the passed internal id, or null if it doesn't exist.
    • internalIds

      List<UUID> internalIds()
      Returns all internal ids of the elements from the list.
    • listenElements

      void listenElements(ConfigurationNamedListListener<VIEWT> listener)
      Add named-list-specific configuration values listener.

      NOTE: If this method is called from another listener, then it is guaranteed to be called starting from the next configuration update only.

      Parameters:
      listener - Listener.
    • stopListenElements

      void stopListenElements(ConfigurationNamedListListener<VIEWT> listener)
      Removes named-list-specific configuration values listener.

      NOTE: Unpredictable behavior if the method is called inside other listeners.

      Parameters:
      listener - Listener.
    • any

      T any()
      Returns a placeholder that allows you to add listeners for changing configuration value of any element of the named list and any of its nested configurations.

      NOTE: ConfigurationListenOnlyException will be thrown when trying to get/update the configuration values.

    • directProxy

      Description copied from interface: ConfigurationProperty
      Returns a configuration tree for the purpose of reading configuration directly from the underlying storage. Actual reading is only happening while invoking ConfigurationProperty.value(). It will either throw NoSuchElementException, unchecked runtime exception, or return the value.

      It is important to understand how it processes named list elements. Imagine having element named a with internalId aId.

      
           var namedListProxy = namedList.directProxy();
      
           // Creates another proxy.
           var aElementProxy = namedListProxy.get("a");
      
           // This operation performs actual reading. It'll throw an exception if element named "a" doesn't exist anymore.
           // It's been renamed or deleted.
           var aElement = aElementProxy.value();
      
           // Creates another proxy.
           var aIdElementProxy = namedListProxy.get(aId);
      
           // This operation performs actual reading as previously stated. But, unlike the access by name, it won't throw an exception in
           // case of a rename. Only after deletion.
           var aIdElement = aIdElementProxy.value();
       

      Another important case is how already resolved named list elements are being proxied.

      
           // Following code is in fact equivalent to a "namedList.directProxy().get(aId);"
           // Already resolved elements are always referenced to by their internal ids. This means that proxy will return a valid value
           // even after rename despite it looking like name "a" should be resolved once again.
           var aElementProxy = namedList.get("a").directProxy();
       
      Specified by:
      directProxy in interface ConfigurationProperty<T extends ConfigurationProperty<VIEWT>>