Interface Configuration


  • public interface Configuration
    Configuration API for accessing property values and registering onChange listeners.
    • Method Detail

      • get

        String get​(String key)
        Return a required configuration value as String.

        IllegalStateException is thrown if the value is not defined in configuration.

        Parameters:
        key - The configuration key
        Returns:
        The configured value
      • get

        String get​(String key,
                   String defaultValue)
        Return a configuration string value with a given default.
        Parameters:
        key - The configuration key
        defaultValue - The default value used
        Returns:
        The configured or default value
      • getOptional

        Optional<StringgetOptional​(String key)
        Return a configuration value that might not exist.
        Parameters:
        key - The configuration key
        Returns:
        The configured value wrapped as optional
      • getBool

        boolean getBool​(String key)
        Return a required boolean configuration value.

        IllegalStateException is thrown if the value is not defined in configuration.

        Parameters:
        key - The configuration key
        Returns:
        The configured value
      • getBool

        boolean getBool​(String key,
                        boolean defaultValue)
        Return a configuration value as boolean given a default value.
        Parameters:
        key - The configuration key
        defaultValue - The default value used
        Returns:
        The configured or default value
      • getInt

        int getInt​(String key)
        Return a required int configuration value.

        IllegalStateException is thrown if the value is not defined in configuration.

        Parameters:
        key - The configuration key
        Returns:
        The configured value
      • getInt

        int getInt​(String key,
                   int defaultValue)
        Return a configuration value as int given a default value.
        Parameters:
        key - The configuration key
        defaultValue - The default value used
        Returns:
        The configured or default value
      • getLong

        long getLong​(String key)
        Return a required long configuration value.

        IllegalStateException is thrown if the value is not defined in configuration.

        Parameters:
        key - The configuration key
        Returns:
        The configured value
      • getLong

        long getLong​(String key,
                     long defaultValue)
        Return a configuration value as long given a default value.
        Parameters:
        key - The configuration key
        defaultValue - The default value used
        Returns:
        The configured or default value
      • setProperty

        void setProperty​(String key,
                         String value)
        Set a configuration value.

        This will fire an configuration callback listeners that are registered for this key.

      • onChange

        void onChange​(String key,
                      Consumer<String> callback)
        Register a callback for a change to the given configuration key.
        Parameters:
        key - The configuration key we want to detect changes to
        callback - The callback handling to fire when the configuration changes.
      • onChangeInt

        void onChangeInt​(String key,
                         Consumer<Integer> callback)
        Register a callback for a change to the given configuration key as an Int value.
        Parameters:
        key - The configuration key we want to detect changes to
        callback - The callback handling to fire when the configuration changes.
      • onChangeLong

        void onChangeLong​(String key,
                          Consumer<Long> callback)
        Register a callback for a change to the given configuration key as an Long value.
        Parameters:
        key - The configuration key we want to detect changes to
        callback - The callback handling to fire when the configuration changes.
      • onChangeBool

        void onChangeBool​(String key,
                          Consumer<Boolean> callback)
        Register a callback for a change to the given configuration key as an Boolean value.
        Parameters:
        key - The configuration key we want to detect changes to
        callback - The callback handling to fire when the configuration changes.