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
    DelegatedConfig(@NotNull Config delegate)
    Creates a new instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(@NotBlank String key)
    Returns true if the property with the key passed as argument has been configured.
    get(@NotBlank String key)
    Returns the value of the configuration parameter as String.
    get(@NotBlank String key, @NotNull Supplier<String> defaultValue)
    Returns the value of the configuration parameter as String.
    get(@NotBlank String key, String defaultValue)
    Returns the value of the configuration parameter as String.
    getBoolean(@NotBlank String key)
    Returns the value of the configuration parameter as Boolean.
    boolean
    getBoolean(@NotBlank String key, boolean defaultValue)
    Returns the value of the configuration parameter as Boolean.
    getBoolean(@NotBlank String key, @NotNull Supplier<Boolean> defaultValue)
    Returns the value of the configuration parameter as Boolean.
    protected @NotNull Config
    Returns the delegate configuration.
    getInteger(@NotBlank String key, @NotNull Supplier<Integer> defaultValue)
    Returns the value of the configuration parameter as Boolean.
    getInteger(@NotNull String key)
    Returns the integer value of the specified configuration property, with variable substitution.
    int
    getInteger(@NotNull String key, int defaultValue)
    Returns the integer value of the specified configuration property, with variable substitution.
    @NotNull Stream<String>
    Returns the configuration property keys contained in this configuration.
    @NotNull Stream<String>
    getKeys(@NotNull String prefix)
    Returns the configuration property keys contained in this configuration that start with the specified prefix.
    @NotNull Stream<String>
    getKeys(@NotNull Predicate<String> filter)
    Returns the configuration property keys contained in this configuration that match the specified predicate.
    getLong(@NotBlank String key, @NotNull Supplier<Long> defaultValue)
    Returns the value of the configuration parameter as Boolean.
    getLong(@NotNull String key)
    Returns the integer value of the specified configuration property, with variable substitution.
    long
    getLong(@NotNull String key, long defaultValue)
    Returns the integer value of the specified configuration property, with variable substitution.
    Returns the parent configuration, if any.
    getUndecored(@NotBlank String key)
    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(@NotNull @NotNull Config delegate)
      Creates a new instance.
      Parameters:
      delegate - The configuration to delegate to.
  • Method Details

    • getDelegate

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

      public 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(@NotBlank @NotBlank 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

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

      @NotNull public @NotNull Stream<String> getKeys(@NotNull @NotNull 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

      @NotNull public @NotNull Stream<String> getKeys(@NotNull @NotNull 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(@NotBlank @NotBlank 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 String getUndecored(@NotBlank @NotBlank 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 String get(@NotBlank @NotBlank String key, 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 String get(@NotBlank @NotBlank String key, @NotNull @NotNull Supplier<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 Boolean getBoolean(@NotBlank @NotBlank 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(@NotBlank @NotBlank 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 Boolean getBoolean(@NotBlank @NotBlank String key, @NotNull @NotNull Supplier<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 Integer getInteger(@NotNull @NotNull 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(@NotNull @NotNull 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 Integer getInteger(@NotBlank @NotBlank String key, @NotNull @NotNull Supplier<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 Long getLong(@NotNull @NotNull 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(@NotNull @NotNull 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 Long getLong(@NotBlank @NotBlank String key, @NotNull @NotNull Supplier<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