Package com.helger.config.fallback
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>
The default implementation of
IConfigWithFallback.- Since:
- 10.2.0
- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IConfigKeyOutdatedNotifierThe default implementation that just logs a warning.Fields inherited from class com.helger.config.Config
DEFAULT_REPLACE_VARIABLES, DEFAULT_UNRESOLVED_VARIABLE_PROVIDER, DEFAULT_USE_VARIABLE_DEFAULT_VALUES -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAsBigDecimalOrFallback(String sPrimary, String... aOldOnes) Get the configuration value as a BigDecimal based on the primary or the alternative keys.char[]getAsCharArrayOrFallback(String sPrimary, String... aOldOnes) Get the configuration value as a char array based on the primary or the alternative keys.intgetAsIntOrFallback(String sPrimary, int nBogus, int nDefault, String... aOldOnes) Get the configuration value as a int based on the primary or the alternative keys.longgetAsLongOrFallback(String sPrimary, long nBogus, long nDefault, String... aOldOnes) Get the configuration value as a long based on the primary or the alternative keys.getAsStringOrFallback(String sPrimary, String... aOldOnes) Get the configuration value as a String based on the primary or the alternative keys.getConfiguredValueOrFallback(String sPrimary, String... aOldOnes) Get theConfiguredValuebased on the primary or the alternative keys.final ConfigWithFallbacksetOutdatedNotifier(IConfigKeyOutdatedNotifier aOutdatedNotifier) Set the outdated key notifier to be invoked when an old configuration key was used.toString()Methods inherited from class com.helger.config.Config
create, forEachConfigurationValueProvider, forEachConfigurationValueProviderRecursive, getConfigurationValueProvider, getConfiguredValue, getFoundKeyConsumer, getKeyNotFoundConsumer, getUnresolvedVariableProvider, getValue, isReplaceVariables, isUseVariableDefaultValues, setFoundKeyConsumer, setKeyNotFoundConsumer, setReplaceVariables, setUnresolvedVariableProvider, setUseVariableDefaultValuesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.config.IConfig
forEachConfigurationValueProvider, getConfiguredValue, getResourceBasedConfigurationValueProviderCount, reloadAllResourceBasedConfigurationValuesMethods inherited from interface com.helger.typeconvert.trait.IGetterByKeyTrait
containsNonNullValue, containsNullValue, getAsBigDecimal, getAsBigDecimal, getAsBigInteger, getAsBigInteger, getAsBoolean, getAsBoolean, getAsBooleanObj, getAsByte, getAsByte, getAsByteArray, getAsByteObj, getAsChar, getAsChar, getAsCharArray, getAsCharArray, getAsCharObj, getAsDouble, getAsDouble, getAsDoubleObj, getAsFloat, getAsFloat, getAsFloatObj, getAsInt, getAsInt, getAsIntObj, getAsLocalDate, getAsLocalDate, getAsLocalDateTime, getAsLocalDateTime, getAsLocalTime, getAsLocalTime, getAsLong, getAsLong, getAsLongObj, getAsShort, getAsShort, getAsShortObj, getAsSqlBlob, getAsSqlClob, getAsSqlDate, getAsSqlNClob, getAsSqlRowId, getAsSqlTime, getAsSqlTimestamp, getAsString, getAsString, getAsStringList, getAsStringList, getAsStringSet, getAsStringSet, getCastedValue, getCastedValue, getCastedValue, getCastedValue, getConvertedValue, getConvertedValue, getSafeCastedValue, getSafeCastedValue, getValue, getValueClass, hasStringValue, hasStringValue, onSafeCastError
-
Field Details
-
DEFAULT_OUTDATED_NOTIFIER
The default implementation that just logs a warning.
-
-
Constructor Details
-
ConfigWithFallback
-
-
Method Details
-
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 benull.- Returns:
- this for chaining
-
getConfiguredValueOrFallback
@Nullable public ConfiguredValue getConfiguredValueOrFallback(@Nonnull String sPrimary, @Nonnull String... aOldOnes) Description copied from interface:IConfigWithFallbackGet theConfiguredValuebased on the primary or the alternative keys.- Specified by:
getConfiguredValueOrFallbackin interfaceIConfigWithFallback- Parameters:
sPrimary- Primary configuration key. Should not benull.aOldOnes- The alternative keys to be resolved in the provided order. May neither benullnor empty.- Returns:
nullif 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:IConfigWithFallbackGet the configuration value as a String based on the primary or the alternative keys.- Specified by:
getAsStringOrFallbackin interfaceIConfigWithFallback- Parameters:
sPrimary- Primary configuration key. Should not benull.aOldOnes- The alternative keys to be resolved in the provided order. May neither benullnor empty.- Returns:
nullif 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:IConfigWithFallbackGet the configuration value as a char array based on the primary or the alternative keys.- Specified by:
getAsCharArrayOrFallbackin interfaceIConfigWithFallback- Parameters:
sPrimary- Primary configuration key. Should not benull.aOldOnes- The alternative keys to be resolved in the provided order. May neither benullnor empty.- Returns:
nullif 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:IConfigWithFallbackGet the configuration value as a BigDecimal based on the primary or the alternative keys.- Specified by:
getAsBigDecimalOrFallbackin interfaceIConfigWithFallback- Parameters:
sPrimary- Primary configuration key. Should not benull.aOldOnes- The alternative keys to be resolved in the provided order. May neither benullnor empty.- Returns:
nullif 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:IConfigWithFallbackGet the configuration value as a int based on the primary or the alternative keys.- Specified by:
getAsIntOrFallbackin interfaceIConfigWithFallback- Parameters:
sPrimary- Primary configuration key. Should not benull.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 benullnor empty.- Returns:
nullif 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:IConfigWithFallbackGet the configuration value as a long based on the primary or the alternative keys.- Specified by:
getAsLongOrFallbackin interfaceIConfigWithFallback- Parameters:
sPrimary- Primary configuration key. Should not benull.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 benullnor empty.- Returns:
nullif neither the primary nor the old configuration property keys could be resolved.
-
toString
-