org.springframework.core.env
Class PropertySourcesPropertyResolver
- java.lang.Object
-
- org.springframework.core.env.AbstractPropertyResolver
-
- org.springframework.core.env.PropertySourcesPropertyResolver
-
- All Implemented Interfaces:
- ConfigurablePropertyResolver, PropertyResolver
public class PropertySourcesPropertyResolver extends AbstractPropertyResolver
PropertyResolver
implementation that resolves property values against an underlying set ofPropertySources
.- Since:
- 3.1
- Author:
- Chris Beams
- See Also:
-
PropertySource
,PropertySources
,AbstractEnvironment
-
Field Summary
Fields inherited from class org.springframework.core.env.AbstractPropertyResolver
conversionService, logger
Constructor Summary
Constructors Constructor and Description PropertySourcesPropertyResolver(PropertySources propertySources)
Create a new resolver against the given property sources.
Method Summary
Methods Modifier and Type Method and Description boolean
containsProperty(String key)
Return whether the given property key is available for resolution, i.e., the value for the given key is notnull
.String
getProperty(String key)
Return the property value associated with the given key, ornull
if the key cannot be resolved.<T> T
getProperty(String key, Class<T> targetValueType)
Return the property value associated with the given key, ornull
if the key cannot be resolved.protected <T> T
getProperty(String key, Class<T> targetValueType, boolean resolveNestedPlaceholders)
<T> Class<T>
getPropertyAsClass(String key, Class<T> targetValueType)
Convert the property value associated with the given key to aClass
of typeT
ornull
if the key cannot be resolved.protected String
getPropertyAsRawString(String key)
Retrieve the specified property as a raw String, i.e.Methods inherited from class org.springframework.core.env.AbstractPropertyResolver
getConversionService, getProperty, getProperty, getRequiredProperty, getRequiredProperty, resolveNestedPlaceholders, resolvePlaceholders, resolveRequiredPlaceholders, setConversionService, setIgnoreUnresolvableNestedPlaceholders, setPlaceholderPrefix, setPlaceholderSuffix, setRequiredProperties, setValueSeparator, validateRequiredProperties
-
Constructor Detail
PropertySourcesPropertyResolver
public PropertySourcesPropertyResolver(PropertySources propertySources)
Create a new resolver against the given property sources.- Parameters:
-
propertySources
- the set ofPropertySource
objects to use
Method Detail
containsProperty
public boolean containsProperty(String key)
Description copied from interface:PropertyResolver
Return whether the given property key is available for resolution, i.e., the value for the given key is notnull
.
getProperty
public String getProperty(String key)
Description copied from interface:PropertyResolver
Return the property value associated with the given key, ornull
if the key cannot be resolved.- Parameters:
-
key
- the property name to resolve - See Also:
-
PropertyResolver.getProperty(String, String)
,PropertyResolver.getProperty(String, Class)
,PropertyResolver.getRequiredProperty(String)
getProperty
public <T> T getProperty(String key, Class<T> targetValueType)
Description copied from interface:PropertyResolver
Return the property value associated with the given key, ornull
if the key cannot be resolved.- Parameters:
-
key
- the property name to resolve -
targetValueType
- the expected type of the property value - See Also:
-
PropertyResolver.getRequiredProperty(String, Class)
getPropertyAsRawString
protected String getPropertyAsRawString(String key)
Description copied from class:AbstractPropertyResolver
Retrieve the specified property as a raw String, i.e. without resolution of nested placeholders.- Specified by:
-
getPropertyAsRawString
in classAbstractPropertyResolver
- Parameters:
-
key
- the property name to resolve - Returns:
-
the property value or
null
if none found
getProperty
protected <T> T getProperty(String key, Class<T> targetValueType, boolean resolveNestedPlaceholders)
getPropertyAsClass
public <T> Class<T> getPropertyAsClass(String key, Class<T> targetValueType)
Description copied from interface:PropertyResolver
Convert the property value associated with the given key to aClass
of typeT
ornull
if the key cannot be resolved.