public interface PropertyResolver
Environment
,
PropertySourcesPropertyResolver
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> targetType)
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> targetType,
T defaultValue)
Return the property value associated with the given key,
or
defaultValue if the key cannot be resolved. |
java.lang.String |
getProperty(java.lang.String key,
java.lang.String defaultValue)
Return the property value associated with the given key, or
defaultValue if the key cannot be resolved. |
java.lang.String |
getRequiredProperty(java.lang.String key)
Return the property value associated with the given key (never
null ). |
<T> T |
getRequiredProperty(java.lang.String key,
java.lang.Class<T> targetType)
Return the property value associated with the given key, converted to the given
targetType (never
null ). |
java.lang.String |
resolvePlaceholders(java.lang.String text)
Resolve ${...} placeholders in the given text, replacing them with corresponding
property values as resolved by
getProperty(java.lang.String) . |
java.lang.String |
resolveRequiredPlaceholders(java.lang.String text)
Resolve ${...} placeholders in the given text, replacing them with corresponding
property values as resolved by
getProperty(java.lang.String) . |
boolean containsProperty(java.lang.String key)
null
.@Nullable java.lang.String getProperty(java.lang.String key)
null
if the key cannot be resolved.key
- the property name to resolvegetProperty(String, String)
,
getProperty(String, Class)
,
getRequiredProperty(String)
java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
defaultValue
if the key cannot be resolved.key
- the property name to resolvedefaultValue
- the default value to return if no value is foundgetRequiredProperty(String)
,
getProperty(String, Class)
@Nullable <T> T getProperty(java.lang.String key, java.lang.Class<T> targetType)
null
if the key cannot be resolved.key
- the property name to resolvetargetType
- the expected type of the property valuegetRequiredProperty(String, Class)
<T> T getProperty(java.lang.String key, java.lang.Class<T> targetType, T defaultValue)
defaultValue
if the key cannot be resolved.key
- the property name to resolvetargetType
- the expected type of the property valuedefaultValue
- the default value to return if no value is foundgetRequiredProperty(String, Class)
java.lang.String getRequiredProperty(java.lang.String key) throws java.lang.IllegalStateException
null
).java.lang.IllegalStateException
- if the key cannot be resolvedgetRequiredProperty(String, Class)
<T> T getRequiredProperty(java.lang.String key, java.lang.Class<T> targetType) throws java.lang.IllegalStateException
null
).java.lang.IllegalStateException
- if the given key cannot be resolvedjava.lang.String resolvePlaceholders(java.lang.String text)
getProperty(java.lang.String)
. Unresolvable placeholders with
no default value are ignored and passed through unchanged.text
- the String to resolvenull
)java.lang.IllegalArgumentException
- if given text is null
resolveRequiredPlaceholders(java.lang.String)
,
SystemPropertyUtils.resolvePlaceholders(String)
java.lang.String resolveRequiredPlaceholders(java.lang.String text) throws java.lang.IllegalArgumentException
getProperty(java.lang.String)
. Unresolvable placeholders with
no default value will cause an IllegalArgumentException to be thrown.null
)java.lang.IllegalArgumentException
- if given text is null
or if any placeholders are unresolvableSystemPropertyUtils.resolvePlaceholders(String, boolean)