T
- The target type of the configuration entry.public static interface ConfigResolver.TypedResolver<T>
Modifier and Type | Method and Description |
---|---|
ConfigResolver.TypedResolver<List<T>> |
asList()
Declare the Resolver to return a List of the given Type.
|
ConfigResolver.TypedResolver<T> |
cacheFor(TimeUnit timeUnit,
long value)
Specify that a resolved value will get cached for a certain amount of time.
|
ConfigResolver.TypedResolver<T> |
evaluateVariables(boolean evaluateVariables)
Whether to evaluate variables in configured values.
|
T |
getDefaultValue()
Returns the default value provided by
withDefault(Object) or withStringDefault(String) . |
String |
getKey()
Returns the key given in
ConfigResolver.resolve(String) . |
String |
getResolvedKey()
Returns the actual key which led to successful resolution and corresponds to the resolved value.
|
T |
getValue()
Returns the converted resolved filtered value.
|
T |
getValue(ConfigSnapshot configSnapshot)
Returns the value from a previously taken
ConfigSnapshot . |
ConfigResolver.TypedResolver<T> |
logChanges(boolean logChanges)
Whether to log picking up any value changes as INFO.
|
ConfigResolver.TypedResolver<T> |
onChange(ConfigResolver.ConfigChanged<T> valueChangedCallback)
A user can register a Callback which gets notified whenever
a config change got detected.
|
ConfigResolver.TypedResolver<T> |
parameterizedBy(String propertyName)
Appends the resolved value of the given property to the key of this builder.
|
ConfigResolver.TypedResolver<T> |
strictly(boolean strictly)
Indicates whether the fallback resolution sequence should be performed, as described in
ConfigResolver.getPropertyAwarePropertyValue(String, String) . |
ConfigResolver.TypedResolver<T> |
withCurrentProjectStage(boolean with)
Indicates whether to append the name of the current project stage to the key of this builder.
|
ConfigResolver.TypedResolver<T> |
withDefault(T value)
Sets the default value to use in case the resolution returns null.
|
ConfigResolver.TypedResolver<T> |
withStringDefault(String value)
Sets the default value to use in case the resolution returns null.
|
ConfigResolver.TypedResolver<List<T>> asList()
ConfigResolver.TypedResolver<T> parameterizedBy(String propertyName)
ConfigResolver.getPropertyAwarePropertyValue(String, String)
.propertyName
- The name of the parameter propertyConfigResolver.TypedResolver<T> withCurrentProjectStage(boolean with)
ConfigResolver.getProjectStageAwarePropertyValue(String)
. True by
default.with
- ConfigResolver.TypedResolver<T> strictly(boolean strictly)
ConfigResolver.getPropertyAwarePropertyValue(String, String)
. This applies only when
parameterizedBy(String)
or withCurrentProjectStage(boolean)
is used.strictly
- ConfigResolver.TypedResolver<T> withDefault(T value)
value
- the default valueConfigResolver.TypedResolver<T> withStringDefault(String value)
value
- string value to be converted and used as defaultConfigResolver.TypedResolver<T> cacheFor(TimeUnit timeUnit, long value)
getValue()
will again resolve the value
from the underlying ConfigResolver
.timeUnit
- the TimeUnit for the valuevalue
- the amount of the TimeUnit to waitConfigResolver.TypedResolver<T> evaluateVariables(boolean evaluateVariables)
mycompany.some.url=${myserver.host}/some/path myserver.host=http://localhost:8081If 'evaluateVariables' is enabled, the result for the above key
"mycompany.some.url"
would be:
"http://localhost:8081/some/path"
evaluateVariables
- whether to evaluate variables in values or notConfigResolver.TypedResolver<T> logChanges(boolean logChanges)
ConfigResolver.TypedResolver<T> onChange(ConfigResolver.ConfigChanged<T> valueChangedCallback)
getValue()
and also inside Config#snapshotFor(TypedResolver...)
.
If a change got detected the will
get invoked in a synchronous way before the getValue()
or Config#snapshotFor(TypedResolver...)
returns.
There can only be a single valueChangedCallback.
Using this method multiple times will replace the previously set callback.valueChangedCallback
- a lambda or implementation which will get invoked
whenever a value change is being detected.T getValue()
T getValue(ConfigSnapshot configSnapshot)
ConfigSnapshot
.IllegalArgumentException
- if the ConfigSnapshot
hasn't been resolved
for this ConfigResolver.TypedResolver
Config#snapshotFor(TypedResolver[])
String getKey()
ConfigResolver.resolve(String)
.String getResolvedKey()
parameterizedBy(String)
or withCurrentProjectStage(boolean)
is used and
strictly(boolean)
is not used, otherwise the resolved key should always be equal to the original
key. This method is provided for cases, when projectStage-aware and/or parameterized resolution is
requested but the value for such appended key is not found and some of the fallback keys is used, as
described in ConfigResolver.getPropertyAwarePropertyValue(String, String)
.
This should be called only after calling getValue()
otherwise the value is undefined (but likely
null).T getDefaultValue()
withDefault(Object)
or withStringDefault(String)
.
Returns null if no default was provided.Copyright © 2021 The Apache Software Foundation. All rights reserved.