Class ConfigurationUpdate

java.lang.Object
org.jgrapes.core.internal.EventBase<T>
org.jgrapes.core.Event<Void>
org.jgrapes.util.events.ConfigurationUpdate
All Implemented Interfaces:
Future<Void>, Associator, Eligible
Direct Known Subclasses:
InitialConfiguration

public class ConfigurationUpdate extends Event<Void>
An event to indicate that configuration information has been updated.

Configuration information provided by this event is organized by paths and associated key/value pairs. The path information should be used by components to select the information important to them. Often, a component simply matches the path from the event with its own path in the component hierarchy (see Manager.componentPath()). But paths can also be used to structure information in a way that is completely independent of the implementation’s structure as the filtering is completely up to the component.

  • Constructor Details

  • Method Details

    • paths

      public Set<String> paths()
      Return all paths affected by this event.
      Returns:
      the paths
    • values

      Return the properties for a given path if any exist.

      If a property has a structured value (list or collection), the values are returned as several entries as described in ConfigurationStore.flatten(Map). All values are converted to their string representation.

      Parameters:
      path - the path
      Returns:
      the updated values or null if the path has been removed (implies the removal of all values for that path).
    • value

      public <T> Optional<T> value(String path, String key, Class<T> as)
      Return the value with the given path and key if it exists and is of or can be converted to the requested type.
      Type Parameters:
      T - the generic type
      Parameters:
      path - the path
      key - the key
      as - the as
      Returns:
      the optional
    • value

      public Optional<String> value(String path, String key)
      Return the value with the given path and key if it exists as string.
      Parameters:
      path - the path
      key - the key
      Returns:
      the value
    • structured

      Return the properties for a given path if they exists as a map with (possibly) structured values (see ConfigurationStore.structured(String)).

      The type of the value depends on the configuration store used. Some configuration stores support types other than string, some don’t. Too avoid any problems, it is strongly recommended to call ConfigurationStore.as(Object, Class) for any value obtained from the result of this method.

      Parameters:
      path - the path
      Returns:
      the updated values or null if the path has been removed (implies the removal of all values for that path).
    • set

      public ConfigurationUpdate set(String path, Map<String,?> values)
      Set new (updated), possibly structured configuration values (see ConfigurationStore.structure(Map) for the given path.

      Any information associated with the path before the invocation of this method is replaced.

      Parameters:
      path - the value’s path
      Returns:
      the event for easy chaining
    • add

      public ConfigurationUpdate add(String path, String selector, Object value)
      Add a new (or updated) configuration value for the given path and key.
      Parameters:
      path - the value’s path
      selector - the key or the path within the structured value
      value - the value
      Returns:
      the event for easy chaining
    • removePath

      Associate the given path with null.

      This signals to handlers that the path has been removed from the configuration.

      Parameters:
      path - the path that has been removed
      Returns:
      the event for easy chaining