Interface PropertyResolver
-
- All Known Implementing Classes:
AbstractPropertyResolver,PropertySourcesPropertyResolver
public interface PropertyResolverInterface for resolving properties against any underlying source.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancontainsProperty(String key)Whether the given property key is available.Optional<String>getProperty(String key)Find the property value associated with the given key.StringgetProperty(String key, String defaultValue)Find the property value associated with the given key.<R,T>
Optional<T>getProperty(String key, Function<R,T> mappingFunction)Find the property value associated with the given key.<R,T>
TgetProperty(String key, Function<R,T> mappingFunction, T defaultValue)Find the property value associated with the given key.StringgetRequiredProperty(String key)Find the property value associated with the given key (nevernull).<R,T>
TgetRequiredProperty(String key, Function<R,T> mappingFunction)Find the property value associated with the given key (nevernull).StringresolvePlaceholders(String text)Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved bygetProperty(java.lang.String).StringresolveRequiredPlaceholders(String text)Resolve ${...} placeholders in the given text, replacing them with corresponding property values as resolved bygetProperty(java.lang.String).voidsetPlaceholderPrefix(String placeholderPrefix)Set the prefix that placeholders replaced by this resolver must begin with.voidsetPlaceholderSuffix(String placeholderSuffix)Set the suffix that placeholders replaced by this resolver must end with.voidsetValueSeparator(String valueSeparator)Specify the separating character between the placeholders replaced by this resolver and their associated default value, ornullif no such special character should be processed as a value separator.
-
-
-
Method Detail
-
containsProperty
boolean containsProperty(String key)
Whether the given property key is available.- Returns:
- true if the given property key is available for resolution otherwise false.
-
getProperty
Optional<String> getProperty(String key)
Find the property value associated with the given key.Optional.empty()will be returned if the key cannot be resolved.- Parameters:
key- the property name to resolve- Returns:
- property value
- See Also:
getProperty(String, String),getProperty(String, Function),getRequiredProperty(String)
-
getProperty
String getProperty(String key, String defaultValue)
Find the property value associated with the given key. If the associated property value not found, defaultValue will be returned.- Parameters:
key- the property name to resolvedefaultValue- the default value to return if no value is found- Returns:
- property value
- See Also:
getRequiredProperty(String),getProperty(String, Function)
-
getProperty
<R,T> Optional<T> getProperty(String key, Function<R,T> mappingFunction)
Find the property value associated with the given key.Optional.empty()will be returned if the key cannot be resolved.- Parameters:
key- the property name to resolvemappingFunction- the mapping function convert original object to target objet.- Returns:
- property value
- See Also:
getRequiredProperty(String, Function)
-
getProperty
<R,T> T getProperty(String key, Function<R,T> mappingFunction, T defaultValue)
Find the property value associated with the given key. If the associated property value not found, defaultValue will be returned.- Parameters:
key- the property name to resolvemappingFunction- the mapping function convert original object to target objetdefaultValue- the default value to return if no value is found- Returns:
- property value
- See Also:
getRequiredProperty(String, Function)
-
getRequiredProperty
String getRequiredProperty(String key) throws IllegalStateException
Find the property value associated with the given key (nevernull).- Parameters:
key- the property name to resolve- Returns:
- property value
- Throws:
IllegalStateException- if the key cannot be resolved- See Also:
getRequiredProperty(String, Function)
-
getRequiredProperty
<R,T> T getRequiredProperty(String key, Function<R,T> mappingFunction) throws IllegalStateException
Find the property value associated with the given key (nevernull).- Parameters:
key- the property name to resolvemappingFunction- the mapping function convert original object to target objet- Returns:
- property value
- Throws:
IllegalStateException- if the given key cannot be resolved
-
resolvePlaceholders
String resolvePlaceholders(String text)
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 param isnull- See Also:
resolveRequiredPlaceholders(java.lang.String)
-
resolveRequiredPlaceholders
String resolveRequiredPlaceholders(String text) throws IllegalArgumentException
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 isnullor if any placeholders are unresolvable
-
setPlaceholderPrefix
void setPlaceholderPrefix(String placeholderPrefix)
Set the prefix that placeholders replaced by this resolver must begin with.
-
setPlaceholderSuffix
void setPlaceholderSuffix(String placeholderSuffix)
Set the suffix that placeholders replaced by this resolver must end with.
-
setValueSeparator
void setValueSeparator(String valueSeparator)
Specify the separating character between the placeholders replaced by this resolver and their associated default value, ornullif no such special character should be processed as a value separator.
-
-