Class PropertySourcesPropertyResolver
- java.lang.Object
-
- cn.sliew.milky.common.environment.AbstractPropertyResolver
-
- cn.sliew.milky.common.environment.PropertySourcesPropertyResolver
-
- All Implemented Interfaces:
PropertyResolver
public class PropertySourcesPropertyResolver extends AbstractPropertyResolver
-
-
Field Summary
-
Fields inherited from class cn.sliew.milky.common.environment.AbstractPropertyResolver
log
-
-
Constructor Summary
Constructors Constructor Description PropertySourcesPropertyResolver(PropertySourceIterable propertySources)
-
Method Summary
All Methods Instance Methods Concrete 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.<R,T>
Optional<T>getProperty(String key, Function<R,T> mappingFunction)Find the property value associated with the given key.protected <R,T>
TgetProperty(String key, Function<R,T> mappingFunction, boolean resolveNestedPlaceholders)protected Optional<String>getPropertyAsRawString(String key)Retrieve the specified property as a raw String, i.e.protected voidlogKeyFound(String key, PropertySource<?> propertySource, Object value)Log the given key as found in the givenPropertySource, resulting in the given value.-
Methods inherited from class cn.sliew.milky.common.environment.AbstractPropertyResolver
getProperty, getProperty, getRequiredProperty, getRequiredProperty, resolveNestedPlaceholders, resolvePlaceholders, resolveRequiredPlaceholders, setPlaceholderPrefix, setPlaceholderSuffix, setValueSeparator
-
-
-
-
Constructor Detail
-
PropertySourcesPropertyResolver
public PropertySourcesPropertyResolver(PropertySourceIterable propertySources)
-
-
Method Detail
-
containsProperty
public boolean containsProperty(String key)
Description copied from interface:PropertyResolverWhether the given property key is available.- Specified by:
containsPropertyin interfacePropertyResolver- Overrides:
containsPropertyin classAbstractPropertyResolver- Returns:
- true if the given property key is available for resolution otherwise false.
-
getProperty
public Optional<String> getProperty(String key)
Description copied from interface:PropertyResolverFind 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:
PropertyResolver.getProperty(String, String),PropertyResolver.getProperty(String, Function),PropertyResolver.getRequiredProperty(String)
-
getProperty
public <R,T> Optional<T> getProperty(String key, Function<R,T> mappingFunction)
Description copied from interface:PropertyResolverFind 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:
PropertyResolver.getRequiredProperty(String, Function)
-
getPropertyAsRawString
protected Optional<String> getPropertyAsRawString(String key)
Description copied from class:AbstractPropertyResolverRetrieve the specified property as a raw String, i.e. without resolution of nested placeholders.- Specified by:
getPropertyAsRawStringin classAbstractPropertyResolver- Parameters:
key- the property name to resolve- Returns:
- the property value or
Optional.empty()if none found
-
getProperty
protected <R,T> T getProperty(String key, Function<R,T> mappingFunction, boolean resolveNestedPlaceholders)
-
logKeyFound
protected void logKeyFound(String key, PropertySource<?> propertySource, Object value)
Log the given key as found in the givenPropertySource, resulting in the given value.
-
-