Class ConfigWithFallback

java.lang.Object
com.helger.config.Config
com.helger.config.fallback.ConfigWithFallback
All Implemented Interfaces:
IConfigWithFallback, IConfig, com.helger.typeconvert.trait.IGetterByKeyTrait<String>

public class ConfigWithFallback extends Config implements IConfigWithFallback
The default implementation of IConfigWithFallback.
Since:
10.2.0
Author:
Philip Helger
  • Field Details

    • DEFAULT_OUTDATED_NOTIFIER

      public static final IConfigKeyOutdatedNotifier DEFAULT_OUTDATED_NOTIFIER
      The default implementation that just logs a warning.
  • Constructor Details

  • Method Details

    • getOutdatedNotifier

      @Nonnull public final IConfigKeyOutdatedNotifier getOutdatedNotifier()
      Returns:
      The outdated key notifier to be invoked, when an old configuration key was used. Never null.
    • setOutdatedNotifier

      @Nonnull public final ConfigWithFallback setOutdatedNotifier(@Nonnull IConfigKeyOutdatedNotifier aOutdatedNotifier)
      Set the outdated key notifier to be invoked when an old configuration key was used.
      Parameters:
      aOutdatedNotifier - The outdated key identifier to be used. May not be null.
      Returns:
      this for chaining
    • getConfiguredValueOrFallback

      @Nullable public ConfiguredValue getConfiguredValueOrFallback(@Nonnull String sPrimary, @Nonnull String... aOldOnes)
      Description copied from interface: IConfigWithFallback
      Get the ConfiguredValue based on the primary or the alternative keys.
      Specified by:
      getConfiguredValueOrFallback in interface IConfigWithFallback
      Parameters:
      sPrimary - Primary configuration key. Should not be null.
      aOldOnes - The alternative keys to be resolved in the provided order. May neither be null nor empty.
      Returns:
      null if neither the primary nor the old configuration property keys could be resolved.
      See Also:
    • getAsStringOrFallback

      @Nullable public String getAsStringOrFallback(@Nonnull String sPrimary, @Nonnull String... aOldOnes)
      Description copied from interface: IConfigWithFallback
      Get the configuration value as a String based on the primary or the alternative keys.
      Specified by:
      getAsStringOrFallback in interface IConfigWithFallback
      Parameters:
      sPrimary - Primary configuration key. Should not be null.
      aOldOnes - The alternative keys to be resolved in the provided order. May neither be null nor empty.
      Returns:
      null if neither the primary nor the old configuration property keys could be resolved.
    • getAsCharArrayOrFallback

      @Nullable public char[] getAsCharArrayOrFallback(@Nonnull String sPrimary, @Nonnull String... aOldOnes)
      Description copied from interface: IConfigWithFallback
      Get the configuration value as a char array based on the primary or the alternative keys.
      Specified by:
      getAsCharArrayOrFallback in interface IConfigWithFallback
      Parameters:
      sPrimary - Primary configuration key. Should not be null.
      aOldOnes - The alternative keys to be resolved in the provided order. May neither be null nor empty.
      Returns:
      null if neither the primary nor the old configuration property keys could be resolved.
    • getAsBigDecimalOrFallback

      @Nullable public BigDecimal getAsBigDecimalOrFallback(@Nonnull String sPrimary, @Nonnull String... aOldOnes)
      Description copied from interface: IConfigWithFallback
      Get the configuration value as a BigDecimal based on the primary or the alternative keys.
      Specified by:
      getAsBigDecimalOrFallback in interface IConfigWithFallback
      Parameters:
      sPrimary - Primary configuration key. Should not be null.
      aOldOnes - The alternative keys to be resolved in the provided order. May neither be null nor empty.
      Returns:
      null if neither the primary nor the old configuration property keys could be resolved.
    • getAsIntOrFallback

      public int getAsIntOrFallback(@Nonnull String sPrimary, int nBogus, int nDefault, @Nonnull String... aOldOnes)
      Description copied from interface: IConfigWithFallback
      Get the configuration value as a int based on the primary or the alternative keys.
      Specified by:
      getAsIntOrFallback in interface IConfigWithFallback
      Parameters:
      sPrimary - Primary configuration key. Should not be null.
      nBogus - A value that is considered invalid for all (primary and old ones) to indicate that the other values need to be searched as well.
      nDefault - The value to be returned if none of the keys could be resolved.
      aOldOnes - The alternative keys to be resolved in the provided order. May neither be null nor empty.
      Returns:
      null if neither the primary nor the old configuration property keys could be resolved.
    • getAsLongOrFallback

      public long getAsLongOrFallback(@Nonnull String sPrimary, long nBogus, long nDefault, @Nonnull String... aOldOnes)
      Description copied from interface: IConfigWithFallback
      Get the configuration value as a long based on the primary or the alternative keys.
      Specified by:
      getAsLongOrFallback in interface IConfigWithFallback
      Parameters:
      sPrimary - Primary configuration key. Should not be null.
      nBogus - A value that is considered invalid for all (primary and old ones) to indicate that the other values need to be searched as well.
      nDefault - The value to be returned if none of the keys could be resolved.
      aOldOnes - The alternative keys to be resolved in the provided order. May neither be null nor empty.
      Returns:
      null if neither the primary nor the old configuration property keys could be resolved.
    • toString

      public String toString()
      Overrides:
      toString in class Config