Package org.springframework.core.env
Interface PropertyResolver
- All Known Subinterfaces:
ConfigurableEnvironment
,ConfigurablePropertyResolver
,ConfigurableWebEnvironment
,Environment
- All Known Implementing Classes:
AbstractEnvironment
,AbstractPropertyResolver
,MockEnvironment
,PropertySourcesPropertyResolver
,StandardEnvironment
,StandardServletEnvironment
public interface PropertyResolver
Interface for resolving properties against any underlying source.
- Since:
- 3.1
- Author:
- Chris Beams, Juergen Hoeller
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
containsProperty
(String key) Return whether the given property key is available for resolution, i.e.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> targetType) Return the property value associated with the given key, ornull
if the key cannot be resolved.<T> T
getProperty
(String key, Class<T> targetType, T defaultValue) Return the property value associated with the given key, ordefaultValue
if the key cannot be resolved.getProperty
(String key, String defaultValue) Return the property value associated with the given key, ordefaultValue
if the key cannot be resolved.Return the property value associated with the given key (nevernull
).<T> T
getRequiredProperty
(String key, Class<T> targetType) Return the property value associated with the given key, converted to the given targetType (nevernull
).resolvePlaceholders
(String text) Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved bygetProperty(java.lang.String)
.Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved bygetProperty(java.lang.String)
.
-
Method Details
-
containsProperty
Return whether the given property key is available for resolution, i.e. if the value for the given key is notnull
. -
getProperty
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:
-
getProperty
Return the property value associated with the given key, ordefaultValue
if the key cannot be resolved.- Parameters:
key
- the property name to resolvedefaultValue
- the default value to return if no value is found- See Also:
-
getProperty
Return the property value associated with the given key, ornull
if the key cannot be resolved.- Parameters:
key
- the property name to resolvetargetType
- the expected type of the property value- See Also:
-
getProperty
Return the property value associated with the given key, ordefaultValue
if the key cannot be resolved.- Parameters:
key
- the property name to resolvetargetType
- the expected type of the property valuedefaultValue
- the default value to return if no value is found- See Also:
-
getRequiredProperty
Return the property value associated with the given key (nevernull
).- Throws:
IllegalStateException
- if the key cannot be resolved- See Also:
-
getRequiredProperty
Return the property value associated with the given key, converted to the given targetType (nevernull
).- Throws:
IllegalStateException
- if the given key cannot be resolved
-
resolvePlaceholders
Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved bygetProperty(java.lang.String)
. Unresolvable placeholders with no default value are ignored and passed through unchanged.- Parameters:
text
- the String to resolve- Returns:
- the resolved String (never
null
) - Throws:
IllegalArgumentException
- if given text isnull
- See Also:
-
resolveRequiredPlaceholders
Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved bygetProperty(java.lang.String)
. Unresolvable placeholders with no default value will cause an IllegalArgumentException to be thrown.- Returns:
- the resolved String (never
null
) - Throws:
IllegalArgumentException
- if given text isnull
or if any placeholders are unresolvable
-