public class PropertySourcesPropertyResolver extends AbstractPropertyResolver
PropertyResolver
implementation that resolves property values against
an underlying set of PropertySources
.PropertySource
,
PropertySources
,
AbstractEnvironment
logger
Constructor and Description |
---|
PropertySourcesPropertyResolver(PropertySources propertySources)
Create a new resolver against the given property sources.
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsProperty(String key)
Return whether the given property key is available for resolution,
i.e.
|
String |
getProperty(String key)
Return the property value associated with the given key,
or
null if the key cannot be resolved. |
<T> T |
getProperty(String key,
Class<T> targetValueType)
Return the property value associated with the given key,
or
null if the key cannot be resolved. |
protected <T> T |
getProperty(String key,
Class<T> targetValueType,
boolean resolveNestedPlaceholders) |
protected String |
getPropertyAsRawString(String key)
Retrieve the specified property as a raw String,
i.e.
|
protected void |
logKeyFound(String key,
PropertySource<?> propertySource,
Object value)
Log the given key as found in the given
PropertySource , resulting in
the given value. |
convertValueIfNecessary, getConversionService, getProperty, getProperty, getRequiredProperty, getRequiredProperty, resolveNestedPlaceholders, resolvePlaceholders, resolveRequiredPlaceholders, setConversionService, setIgnoreUnresolvableNestedPlaceholders, setPlaceholderPrefix, setPlaceholderSuffix, setRequiredProperties, setValueSeparator, validateRequiredProperties
public PropertySourcesPropertyResolver(@Nullable PropertySources propertySources)
propertySources
- the set of PropertySource
objects to usepublic boolean containsProperty(String key)
PropertyResolver
null
.containsProperty
in interface PropertyResolver
containsProperty
in class AbstractPropertyResolver
@Nullable public String getProperty(String key)
PropertyResolver
null
if the key cannot be resolved.getProperty
in interface PropertyResolver
getProperty
in class AbstractPropertyResolver
key
- the property name to resolvePropertyResolver.getProperty(String, String)
,
PropertyResolver.getProperty(String, Class)
,
PropertyResolver.getRequiredProperty(String)
@Nullable public <T> T getProperty(String key, Class<T> targetValueType)
PropertyResolver
null
if the key cannot be resolved.key
- the property name to resolvetargetValueType
- the expected type of the property valuePropertyResolver.getRequiredProperty(String, Class)
@Nullable protected String getPropertyAsRawString(String key)
AbstractPropertyResolver
getPropertyAsRawString
in class AbstractPropertyResolver
key
- the property name to resolvenull
if none found@Nullable protected <T> T getProperty(String key, Class<T> targetValueType, boolean resolveNestedPlaceholders)
protected void logKeyFound(String key, PropertySource<?> propertySource, Object value)
PropertySource
, resulting in
the given value.
The default implementation writes a debug log message with key and source. As of 4.3.3, this does not log the value anymore in order to avoid accidental logging of sensitive settings. Subclasses may override this method to change the log level and/or log message, including the property's value if desired.
key
- the key foundpropertySource
- the PropertySource
that the key has been found invalue
- the corresponding value