public class PropertySourcePropertyResolver extends Object implements PropertyResolver, AutoCloseable
A PropertyResolver that resolves from one or many PropertySource instances.
| Modifier and Type | Class and Description | 
|---|---|
| protected static class  | PropertySourcePropertyResolver.PropertyCatalogThe property catalog to use. | 
| Modifier and Type | Field and Description | 
|---|---|
| protected Map<String,Object>[] | catalog | 
| protected ConversionService<?> | conversionService | 
| protected Map<String,Object>[] | nonGenerated | 
| protected PropertyPlaceholderResolver | propertyPlaceholderResolver | 
| protected Map<String,PropertySource> | propertySources | 
| protected Map<String,Object>[] | rawCatalog | 
| Constructor and Description | 
|---|
| PropertySourcePropertyResolver()Creates a new, initially empty,  PropertySourcePropertyResolver. | 
| PropertySourcePropertyResolver(ConversionService<?> conversionService)Creates a new, initially empty,  PropertySourcePropertyResolverfor the givenConversionService. | 
| PropertySourcePropertyResolver(PropertySource... propertySources)Creates a new  PropertySourcePropertyResolverfor the givenPropertySourceinstances. | 
| Modifier and Type | Method and Description | 
|---|---|
| PropertySourcePropertyResolver | addPropertySource(PropertySource propertySource)Add a  PropertySourceto this resolver. | 
| PropertySourcePropertyResolver | addPropertySource(String name,
                 Map<String,? super Object> values)Add a property source for the given map. | 
| void | close() | 
| boolean | containsProperties(String name)Whether the given property or any nested properties exist for the key given key within this resolver. | 
| boolean | containsProperty(String name)Whether the given property is contained within this resolver. | 
| Map<String,Object> | getAllProperties(StringConvention keyConvention,
                MapFormat.MapTransformation transformation)Returns a combined Map of all properties in the catalog. | 
| Map<String,Object> | getProperties(String name,
             StringConvention keyFormat)Return all the properties under the given key. | 
| <T> Optional<T> | getProperty(String name,
           ArgumentConversionContext<T> conversionContext)Resolve the given property for the given name, type and generic type arguments. | 
| Collection<String> | getPropertyEntries(String name)Returns a collection of properties entries under the given key. | 
| protected void | processPropertySource(PropertySource properties,
                     PropertySource.PropertyConvention convention) | 
| protected void | resetCaches()Subclasses can override to reset caches. | 
| protected Map<String,Object> | resolveEntriesForKey(String name,
                    boolean allowCreate) | 
| protected Map<String,Object> | resolveEntriesForKey(String name,
                    boolean allowCreate,
                    PropertySourcePropertyResolver.PropertyCatalog propertyCatalog) | 
| protected Map<String,Object> | resolveSubMap(String name,
             Map<String,Object> entries,
             ArgumentConversionContext<?> conversionContext) | 
| protected Map<String,Object> | resolveSubMap(String name,
             Map<String,Object> entries,
             ArgumentConversionContext<?> conversionContext,
             StringConvention keyConvention,
             MapFormat.MapTransformation transformation)Resolves a submap for the given name and parameters. | 
| protected Properties | resolveSubProperties(String name,
                    Map<String,Object> entries,
                    ArgumentConversionContext<?> conversionContext) | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitget, getProperties, getProperty, getProperty, getProperty, getProperty, getRequiredProperty, nameOfget, get, getprotected final ConversionService<?> conversionService
protected final PropertyPlaceholderResolver propertyPlaceholderResolver
protected final Map<String,PropertySource> propertySources
public PropertySourcePropertyResolver(ConversionService<?> conversionService)
PropertySourcePropertyResolver for the given ConversionService.conversionService - The ConversionServicepublic PropertySourcePropertyResolver()
PropertySourcePropertyResolver.public PropertySourcePropertyResolver(PropertySource... propertySources)
PropertySourcePropertyResolver for the given PropertySource instances.propertySources - The PropertySource instancespublic PropertySourcePropertyResolver addPropertySource(@Nullable PropertySource propertySource)
PropertySource to this resolver.propertySource - The PropertySource to addPropertySourcePropertyResolverpublic PropertySourcePropertyResolver addPropertySource(String name, @Nullable Map<String,? super Object> values)
name - The name of the property sourcevalues - The valuespublic boolean containsProperty(@Nullable String name)
PropertyResolverWhether the given property is contained within this resolver.
Note that this method will return false for nested properties. In other words given a key of foo.bar this method will
 return false for: resolver.containsProperty("foo")
To check for nested properties using PropertyResolver.containsProperties(String) instead.
containsProperty in interface PropertyResolvername - The name of the propertypublic boolean containsProperties(@Nullable String name)
PropertyResolvercontainsProperties in interface PropertyResolvername - The name of the property@NonNull public Collection<String> getPropertyEntries(@NonNull String name)
PropertyResolver
 datasource.default.url=localhost
 datasource.another.url=someother
 
 Calling getPropertyEntries(String) with a value of datasource will result in a collection
 containing default and other.getPropertyEntries in interface PropertyResolvername - The name to resolve@NonNull public Map<String,Object> getProperties(String name, StringConvention keyFormat)
PropertyResolverStringConvention.RAW.getProperties in interface PropertyResolvername - The namekeyFormat - The key format to use for the keys. Default is kebab-case.public <T> Optional<T> getProperty(@NonNull String name, @NonNull ArgumentConversionContext<T> conversionContext)
PropertyResolverResolve the given property for the given name, type and generic type arguments.
Implementers can choose to implement more intelligent type conversion by analyzing the typeArgument.
getProperty in interface PropertyResolverT - The concrete typename - The nameconversionContext - The conversion contextpublic Map<String,Object> getAllProperties(StringConvention keyConvention, MapFormat.MapTransformation transformation)
keyConvention - The map key conventiontransformation - The map formatprotected Properties resolveSubProperties(String name, Map<String,Object> entries, ArgumentConversionContext<?> conversionContext)
name - The property nameentries - The entriesconversionContext - The conversion contextprotected Map<String,Object> resolveSubMap(String name, Map<String,Object> entries, ArgumentConversionContext<?> conversionContext)
name - The property nameentries - The entriesconversionContext - The conversion context@NonNull protected Map<String,Object> resolveSubMap(String name, Map<String,Object> entries, ArgumentConversionContext<?> conversionContext, @Nullable StringConvention keyConvention, MapFormat.MapTransformation transformation)
name - The nameentries - The entriesconversionContext - The conversion contextkeyConvention - The key convention to usetransformation - The map transformation to applyprotected void processPropertySource(PropertySource properties, PropertySource.PropertyConvention convention)
properties - The property sourceconvention - The property conventionprotected Map<String,Object> resolveEntriesForKey(String name, boolean allowCreate)
name - The nameallowCreate - Whether allows creationprotected Map<String,Object> resolveEntriesForKey(String name, boolean allowCreate, @Nullable PropertySourcePropertyResolver.PropertyCatalog propertyCatalog)
name - The nameallowCreate - Whether allows creationpropertyCatalog - The string conventionprotected void resetCaches()
public void close()
           throws Exception
close in interface AutoCloseableException