Package com.helger.config
Class Config
java.lang.Object
com.helger.config.Config
- Direct Known Subclasses:
ConfigWithFallback
Default implementation of
IConfig. It is recommended to use ConfigFactory for
accessing IConfig objects.- Author:
- Philip Helger
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanFor backwards compatibility reason, variable replacement is enabled by default since v11.0.2.static final UnaryOperator<String> static final booleanBy default the usage of variable default is allowed. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ConfigvoidEnumerate all contained configuration value provider.static voidforEachConfigurationValueProviderRecursive(IConfigurationValueProvider aValueProvider, IConfigurationValueProviderWithPriorityCallback aCallback) getConfiguredValue(String sKey) Get the configured value, which is the combination of the matching configuration source and the value, for the provided key.final BiConsumer<String, ConfiguredValue> final UnaryOperator<String> final booleanfinal booleanfinal ConfigsetFoundKeyConsumer(BiConsumer<String, ConfiguredValue> aKeyFoundConsumer) final ConfigsetKeyNotFoundConsumer(Consumer<String> aKeyNotFoundConsumer) final ConfigsetReplaceVariables(boolean bReplaceVariables) Enable or disable the replacement of variables in configuration values.final ConfigsetUnresolvedVariableProvider(UnaryOperator<String> aUnresolvedVariableProvider) Set the handler to be invoked when a variable could not be resolved.final ConfigsetUseVariableDefaultValues(boolean bUseVariableDefaultValues) Enable or disable the usage of default values in variables of configuration values.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.config.IConfig
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, getValueClass, hasStringValue, hasStringValue, onSafeCastError
-
Field Details
-
DEFAULT_REPLACE_VARIABLES
public static final boolean DEFAULT_REPLACE_VARIABLESFor backwards compatibility reason, variable replacement is enabled by default since v11.0.2.- See Also:
-
DEFAULT_USE_VARIABLE_DEFAULT_VALUES
public static final boolean DEFAULT_USE_VARIABLE_DEFAULT_VALUESBy default the usage of variable default is allowed. Since 11.1.11- See Also:
-
DEFAULT_UNRESOLVED_VARIABLE_PROVIDER
-
-
Constructor Details
-
Config
Constructor- Parameters:
aValueProvider- The main configuration value provider. May not benull.
-
-
Method Details
-
getConfigurationValueProvider
- Returns:
- The configuration value provider as provided in the constructor. Never
null.
-
getFoundKeyConsumer
- Returns:
- The callback to be invoked if a configuration value was found. May be
null.
-
setFoundKeyConsumer
@Nullable public final Config setFoundKeyConsumer(@Nullable BiConsumer<String, ConfiguredValue> aKeyFoundConsumer) - Parameters:
aKeyFoundConsumer- The callback to be invoked if a configuration value was found. The parameters are key and value. May benull.- Returns:
- this for chaining
- Since:
- 9.4.5
-
getKeyNotFoundConsumer
- Returns:
- The callback to be invoked if a configuration value was not found. May be
null.
-
setKeyNotFoundConsumer
@Nullable public final Config setKeyNotFoundConsumer(@Nullable Consumer<String> aKeyNotFoundConsumer) - Parameters:
aKeyNotFoundConsumer- The callback to be invoked if a configuration value was not found. The parameter is the key. May benull.- Returns:
- this for chaining
- Since:
- 9.4.5
-
isReplaceVariables
public final boolean isReplaceVariables()- Returns:
trueif variables in configuration properties should be replaced,falseif not. The default value is true.- Since:
- 10.2.0
-
setReplaceVariables
Enable or disable the replacement of variables in configuration values.- Parameters:
bReplaceVariables-trueto enable replacement,falseto disable it.- Returns:
- this for chaining
- Since:
- 10.2.0
-
isUseVariableDefaultValues
public final boolean isUseVariableDefaultValues()- Returns:
trueif variables are allowed to have default values in the form${variable:default},falseif not. The default value is true.- Since:
- 11.1.1
-
setUseVariableDefaultValues
Enable or disable the usage of default values in variables of configuration values.- Parameters:
bUseVariableDefaultValues-trueto allow the usage,falseto disable it.- Returns:
- this for chaining
- Since:
- 11.1.1
-
getUnresolvedVariableProvider
- Returns:
- The unresolved variable provider to be used. Never
null.
-
setUnresolvedVariableProvider
@Nonnull public final Config setUnresolvedVariableProvider(@Nonnull UnaryOperator<String> aUnresolvedVariableProvider) Set the handler to be invoked when a variable could not be resolved.- Parameters:
aUnresolvedVariableProvider- The unresolved variable provider to be used. May not benull.- Returns:
- this for chaining
- Since:
- 10.2.0
-
getConfiguredValue
Description copied from interface:IConfigGet the configured value, which is the combination of the matching configuration source and the value, for the provided key.- Specified by:
getConfiguredValuein interfaceIConfig- Parameters:
sKey- The configuration key to look up.- Returns:
nullif no such configuration value is available.
-
getValue
- Specified by:
getValuein interfacecom.helger.typeconvert.trait.IGetterByKeyTrait<String>
-
forEachConfigurationValueProviderRecursive
public static void forEachConfigurationValueProviderRecursive(@Nonnull IConfigurationValueProvider aValueProvider, @Nonnull IConfigurationValueProviderWithPriorityCallback aCallback) -
forEachConfigurationValueProvider
public void forEachConfigurationValueProvider(@Nonnull IConfigurationValueProviderWithPriorityCallback aCallback) Description copied from interface:IConfigEnumerate all contained configuration value provider. All items will be enumerated in the order they are checked, so the ones with highest priority first.- Specified by:
forEachConfigurationValueProviderin interfaceIConfig- Parameters:
aCallback- The callback to invoked. May not benull.
-
toString
-
create
-