public class PropertySourcesPropertyResolver extends AbstractPropertyResolver
PropertyResolver
implementation that resolves property values against
an underlying set of PropertySources
.PropertySource
,
PropertySources
,
AbstractEnvironment
Modifier and Type | Field and Description |
---|---|
private PropertySources |
propertySources |
logger
Constructor and Description |
---|
PropertySourcesPropertyResolver(PropertySources propertySources)
Create a new resolver against the given property sources.
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsProperty(java.lang.String key)
Return whether the given property key is available for resolution,
i.e.
|
java.lang.String |
getProperty(java.lang.String key)
Return the property value associated with the given key,
or
null if the key cannot be resolved. |
<T> T |
getProperty(java.lang.String key,
java.lang.Class<T> targetValueType)
Return the property value associated with the given key,
or
null if the key cannot be resolved. |
protected <T> T |
getProperty(java.lang.String key,
java.lang.Class<T> targetValueType,
boolean resolveNestedPlaceholders) |
protected java.lang.String |
getPropertyAsRawString(java.lang.String key)
Retrieve the specified property as a raw String,
i.e.
|
protected void |
logKeyFound(java.lang.String key,
PropertySource<?> propertySource,
java.lang.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
private final PropertySources propertySources
public PropertySourcesPropertyResolver(PropertySources propertySources)
propertySources
- the set of PropertySource
objects to usepublic boolean containsProperty(java.lang.String key)
PropertyResolver
null
.containsProperty
in interface PropertyResolver
containsProperty
in class AbstractPropertyResolver
public java.lang.String getProperty(java.lang.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)
public <T> T getProperty(java.lang.String key, java.lang.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)
protected java.lang.String getPropertyAsRawString(java.lang.String key)
AbstractPropertyResolver
getPropertyAsRawString
in class AbstractPropertyResolver
key
- the property name to resolvenull
if none foundprotected <T> T getProperty(java.lang.String key, java.lang.Class<T> targetValueType, boolean resolveNestedPlaceholders)
protected void logKeyFound(java.lang.String key, PropertySource<?> propertySource, java.lang.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