Class DelegatedConfig

java.lang.Object
dev.orne.config.DelegatedConfig
All Implemented Interfaces:
Config
Direct Known Subclasses:
DelegatedMutableConfig

@API(status=STABLE, since="1.0") public class DelegatedConfig extends Object implements Config
A configuration that delegates all operations to another configuration. This class is useful for creating a proxy or wrapper around an existing configuration instance, allowing for additional behavior or modifications without changing the original configuration.
Since:
1.0
Version:
1.0, 2025-08
Author:
(w) Iker Hernaez
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if the property with the key passed as argument has been configured.
    get(String key)
    Returns the value of the configuration parameter as String.
    @Nullable String
    get(String key, @Nullable String defaultValue)
    Returns the value of the configuration parameter as String.
    @Nullable String
    get(String key, Supplier<@Nullable String> defaultValue)
    Returns the value of the configuration parameter as String.
    @Nullable Boolean
    Returns the value of the configuration parameter as Boolean.
    boolean
    getBoolean(String key, boolean defaultValue)
    Returns the value of the configuration parameter as Boolean.
    @Nullable Boolean
    getBoolean(String key, Supplier<@Nullable Boolean> defaultValue)
    Returns the value of the configuration parameter as Boolean.
    protected Config
    Returns the delegate configuration.
    @Nullable Integer
    Returns the integer value of the specified configuration property, with variable substitution.
    int
    getInteger(String key, int defaultValue)
    Returns the integer value of the specified configuration property, with variable substitution.
    @Nullable Integer
    getInteger(String key, Supplier<@Nullable Integer> defaultValue)
    Returns the value of the configuration parameter as Boolean.
    Returns the configuration property keys contained in this configuration.
    getKeys(String prefix)
    Returns the configuration property keys contained in this configuration that start with the specified prefix.
    Returns the configuration property keys contained in this configuration that match the specified predicate.
    @Nullable Long
    Returns the integer value of the specified configuration property, with variable substitution.
    long
    getLong(String key, long defaultValue)
    Returns the integer value of the specified configuration property, with variable substitution.
    @Nullable Long
    getLong(String key, Supplier<@Nullable Long> defaultValue)
    Returns the value of the configuration parameter as Boolean.
    @Nullable Config
    Returns the parent configuration, if any.
    @Nullable String
    Returns the value of the configuration parameter as String without applying any decoration or transformation.
    boolean
    Returns true if the configuration contains no property.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface dev.orne.config.Config

    as, subset
  • Constructor Details

    • DelegatedConfig

      public DelegatedConfig(Config delegate)
      Creates a new instance.
      Parameters:
      delegate - The configuration to delegate to.
  • Method Details

    • getDelegate

      protected Config getDelegate()
      Returns the delegate configuration.
      Returns:
      The delegate configuration.
    • getParent

      public @Nullable Config getParent()
      Returns the parent configuration, if any.
      Specified by:
      getParent in interface Config
      Returns:
      The parent configuration
    • isEmpty

      public boolean isEmpty()
      Returns true if the configuration contains no property.
      Specified by:
      isEmpty in interface Config
      Returns:
      Returns true if the configuration contains no property.
    • contains

      public boolean contains(String key)
      Returns true if the property with the key passed as argument has been configured.
      Specified by:
      contains in interface Config
      Parameters:
      key - The configuration property.
      Returns:
      Returns true if the property has been configured.
    • getKeys

      public Stream<String> getKeys()
      Returns the configuration property keys contained in this configuration.
      Specified by:
      getKeys in interface Config
      Returns:
      The configuration property keys.
    • getKeys

      public Stream<String> getKeys(Predicate<String> filter)
      Returns the configuration property keys contained in this configuration that match the specified predicate.
      Specified by:
      getKeys in interface Config
      Parameters:
      filter - The predicate to filter the property keys with.
      Returns:
      The configuration property keys that match the predicate.
    • getKeys

      public Stream<String> getKeys(String prefix)
      Returns the configuration property keys contained in this configuration that start with the specified prefix.
      Specified by:
      getKeys in interface Config
      Parameters:
      prefix - The predicate to filter the property keys with.
      Returns:
      The configuration property keys that match the predicate.
    • get

      public String get(String key)
      Returns the value of the configuration parameter as String.
      Specified by:
      get in interface Config
      Parameters:
      key - The configuration property
      Returns:
      The configuration parameter value as String
    • getUndecored

      public @Nullable String getUndecored(String key)
      Returns the value of the configuration parameter as String without applying any decoration or transformation.
      Specified by:
      getUndecored in interface Config
      Parameters:
      key - The configuration property
      Returns:
      The configuration parameter value as String
    • get

      public @Nullable String get(String key, @Nullable String defaultValue)
      Returns the value of the configuration parameter as String.
      Specified by:
      get in interface Config
      Parameters:
      key - The key of the configuration parameter
      defaultValue - The default value to return if the configuration parameter is not set or is null.
      Returns:
      The configuration parameter value as String
    • get

      public @Nullable String get(String key, Supplier<@Nullable String> defaultValue)
      Returns the value of the configuration parameter as String.
      Specified by:
      get in interface Config
      Parameters:
      key - The key of the configuration parameter
      defaultValue - The default value supplier if the configuration parameter is not set or is null.
      Returns:
      The configuration parameter value as String
    • getBoolean

      public @Nullable Boolean getBoolean(String key)
      Returns the value of the configuration parameter as Boolean.
      Specified by:
      getBoolean in interface Config
      Parameters:
      key - The key of the configuration parameter
      Returns:
      The configuration parameter value as Boolean
    • getBoolean

      public boolean getBoolean(String key, boolean defaultValue)
      Returns the value of the configuration parameter as Boolean.
      Specified by:
      getBoolean in interface Config
      Parameters:
      key - The key of the configuration parameter
      defaultValue - The default value to return if the configuration parameter is not set or is null.
      Returns:
      The configuration parameter value as Boolean
    • getBoolean

      public @Nullable Boolean getBoolean(String key, Supplier<@Nullable Boolean> defaultValue)
      Returns the value of the configuration parameter as Boolean.
      Specified by:
      getBoolean in interface Config
      Parameters:
      key - The key of the configuration parameter
      defaultValue - The default value supplier if the configuration parameter is not set or is null.
      Returns:
      The configuration parameter value as Boolean
    • getInteger

      public @Nullable Integer getInteger(String key)
      Returns the integer value of the specified configuration property, with variable substitution.
      Specified by:
      getInteger in interface Config
      Parameters:
      key - The configuration property.
      Returns:
      The value configuration property, if any.
    • getInteger

      public int getInteger(String key, int defaultValue)
      Returns the integer value of the specified configuration property, with variable substitution.
      Specified by:
      getInteger in interface Config
      Parameters:
      key - The configuration property.
      defaultValue - The default value to return if the configuration parameter is not set or is null.
      Returns:
      The value configuration property, if any.
    • getInteger

      public @Nullable Integer getInteger(String key, Supplier<@Nullable Integer> defaultValue)
      Returns the value of the configuration parameter as Boolean.
      Specified by:
      getInteger in interface Config
      Parameters:
      key - The key of the configuration parameter
      defaultValue - The default value supplier if the configuration parameter is not set or is null.
      Returns:
      The configuration parameter value as Boolean
    • getLong

      public @Nullable Long getLong(String key)
      Returns the integer value of the specified configuration property, with variable substitution.
      Specified by:
      getLong in interface Config
      Parameters:
      key - The configuration property.
      Returns:
      The value configuration property, if any.
    • getLong

      public long getLong(String key, long defaultValue)
      Returns the integer value of the specified configuration property, with variable substitution.
      Specified by:
      getLong in interface Config
      Parameters:
      key - The configuration property.
      defaultValue - The default value to return if the configuration parameter is not set or is null.
      Returns:
      The value configuration property, if any.
    • getLong

      public @Nullable Long getLong(String key, Supplier<@Nullable Long> defaultValue)
      Returns the value of the configuration parameter as Boolean.
      Specified by:
      getLong in interface Config
      Parameters:
      key - The key of the configuration parameter
      defaultValue - The default value supplier if the configuration parameter is not set or is null.
      Returns:
      The configuration parameter value as Boolean