public interface PropertyResolver
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
containsProperty(String key)
Whether the given property key is available.
|
Optional<String> |
getProperty(String key)
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> T |
getProperty(String key,
Function<R,T> mappingFunction,
T defaultValue)
Find the property value associated with the given key.
|
String |
getProperty(String key,
String defaultValue)
Find the property value associated with the given key.
|
String |
getRequiredProperty(String key)
Find the property value associated with the given key (never
null). |
<R,T> T |
getRequiredProperty(String key,
Function<R,T> mappingFunction)
Find the property value associated with the given key (never
null). |
String |
resolvePlaceholders(String text)
Resolve ${...} placeholders in the given text, replacing them with corresponding
property values as resolved by
getProperty(java.lang.String). |
String |
resolveRequiredPlaceholders(String text)
Resolve ${...} placeholders in the given text, replacing them with corresponding
property values as resolved by
getProperty(java.lang.String). |
void |
setPlaceholderPrefix(String placeholderPrefix)
Set the prefix that placeholders replaced by this resolver must begin with.
|
void |
setPlaceholderSuffix(String placeholderSuffix)
Set the suffix that placeholders replaced by this resolver must end with.
|
void |
setValueSeparator(String valueSeparator)
Specify the separating character between the placeholders replaced by this
resolver and their associated default value, or
null if no such
special character should be processed as a value separator. |
boolean containsProperty(String key)
Optional<String> getProperty(String key)
Optional.empty() will be returned if the key cannot be resolved.key - the property name to resolvegetProperty(String, String),
getProperty(String, Function),
getRequiredProperty(String)String getProperty(String key, String defaultValue)
key - the property name to resolvedefaultValue - the default value to return if no value is foundgetRequiredProperty(String),
getProperty(String, Function)<R,T> Optional<T> getProperty(String key, Function<R,T> mappingFunction)
Optional.empty() will be returned if the key cannot be resolved.key - the property name to resolvemappingFunction - the mapping function convert original object to target objet.getRequiredProperty(String, Function)<R,T> T getProperty(String key, Function<R,T> mappingFunction, T defaultValue)
key - the property name to resolvemappingFunction - the mapping function convert original object to target objetdefaultValue - the default value to return if no value is foundgetRequiredProperty(String, Function)String getRequiredProperty(String key) throws IllegalStateException
null).key - the property name to resolveIllegalStateException - if the key cannot be resolvedgetRequiredProperty(String, Function)<R,T> T getRequiredProperty(String key, Function<R,T> mappingFunction) throws IllegalStateException
null).key - the property name to resolvemappingFunction - the mapping function convert original object to target objetIllegalStateException - if the given key cannot be resolvedString resolvePlaceholders(String text)
getProperty(java.lang.String). Unresolvable placeholders with
no default value are ignored and passed through unchanged.text - the String to resolvenull)IllegalArgumentException - if given text param is nullresolveRequiredPlaceholders(java.lang.String)String resolveRequiredPlaceholders(String text) throws IllegalArgumentException
getProperty(java.lang.String). Unresolvable placeholders with
no default value will cause an IllegalArgumentException to be thrown.null)IllegalArgumentException - if given text is null
or if any placeholders are unresolvablevoid setPlaceholderPrefix(String placeholderPrefix)
void setPlaceholderSuffix(String placeholderSuffix)
void setValueSeparator(String valueSeparator)
null if no such
special character should be processed as a value separator.Copyright © 2021. All rights reserved.