Class PropertySourcePropertyResolver
java.lang.Object
io.micronaut.context.env.PropertySourcePropertyResolver
- All Implemented Interfaces:
io.micronaut.core.value.PropertyResolver, io.micronaut.core.value.ValueResolver<String>, AutoCloseable
@NullUnmarked
@Internal
public class PropertySourcePropertyResolver
extends Object
implements io.micronaut.core.value.PropertyResolver, AutoCloseable
A PropertyResolver that resolves from one or many PropertySource instances.
- Since:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final io.micronaut.context.env.DefaultPropertyEntryprotected final PropertyPlaceholderResolver -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new, initially empty,PropertySourcePropertyResolver.PropertySourcePropertyResolver(PropertySource @Nullable ... propertySources) Creates a newPropertySourcePropertyResolverfor the givenPropertySourceinstances.PropertySourcePropertyResolver(io.micronaut.core.convert.ConversionService conversionService) Creates a new, initially empty,PropertySourcePropertyResolverfor the givenConversionService.PropertySourcePropertyResolver(io.micronaut.core.convert.ConversionService conversionService, boolean logEnabled) Creates a new, initially empty,PropertySourcePropertyResolverfor the givenConversionService. -
Method Summary
Modifier and TypeMethodDescriptionaddPropertySource(@Nullable PropertySource propertySource) Add aPropertySourceto this resolver.addPropertySource(String name, @Nullable Map<String, ? super Object> values) Add a property source for the given map.voidclose()booleancontainsProperties(@Nullable String name) booleancontainsProperty(@Nullable String name) getAllProperties(io.micronaut.core.naming.conventions.StringConvention keyConvention, io.micronaut.core.convert.format.MapFormat.MapTransformation transformation) Returns a combined Map of all properties in the catalog.getProperties(@Nullable String name, @Nullable io.micronaut.core.naming.conventions.StringConvention keyFormat) <T> Optional<T> getProperty(String name, io.micronaut.core.convert.ArgumentConversionContext<T> conversionContext) getPropertyEntries(String name) getPropertyEntries(String name, io.micronaut.core.value.PropertyCatalog propertyCatalog) getPropertyPathMatches(String pathPattern) protected voidprocessPropertySource(PropertySource properties, PropertySource.PropertyConvention convention) protected voidSubclasses can override to reset caches.resolveEntriesForKey(String name, boolean allowCreate, @Nullable io.micronaut.core.value.PropertyCatalog propertyCatalog) resolveSubMap(String name, Map<String, io.micronaut.context.env.DefaultPropertyEntry> entries, io.micronaut.core.convert.ArgumentConversionContext<?> conversionContext) resolveSubMap(String name, Map<String, io.micronaut.context.env.DefaultPropertyEntry> entries, io.micronaut.core.convert.ArgumentConversionContext<?> conversionContext, @Nullable io.micronaut.core.naming.conventions.StringConvention keyConvention, io.micronaut.core.convert.format.MapFormat.MapTransformation transformation) Resolves a submap for the given name and parameters.protected PropertiesresolveSubProperties(String name, Map<String, io.micronaut.context.env.DefaultPropertyEntry> entries, io.micronaut.core.convert.ArgumentConversionContext<?> conversionContext) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.core.value.PropertyResolver
get, getProperties, getProperty, getProperty, getProperty, getProperty, getRequiredPropertyMethods inherited from interface io.micronaut.core.value.ValueResolver
get, get, get
-
Field Details
-
NULL_ENTRY
public static final io.micronaut.context.env.DefaultPropertyEntry NULL_ENTRY -
propertyPlaceholderResolver
-
-
Constructor Details
-
PropertySourcePropertyResolver
public PropertySourcePropertyResolver(io.micronaut.core.convert.ConversionService conversionService, boolean logEnabled) Creates a new, initially empty,PropertySourcePropertyResolverfor the givenConversionService.- Parameters:
conversionService- TheConversionServicelogEnabled- flag to enable or disable logger
-
PropertySourcePropertyResolver
public PropertySourcePropertyResolver(io.micronaut.core.convert.ConversionService conversionService) Creates a new, initially empty,PropertySourcePropertyResolverfor the givenConversionService.- Parameters:
conversionService- TheConversionService
-
PropertySourcePropertyResolver
public PropertySourcePropertyResolver()Creates a new, initially empty,PropertySourcePropertyResolver. -
PropertySourcePropertyResolver
Creates a newPropertySourcePropertyResolverfor the givenPropertySourceinstances.- Parameters:
propertySources- ThePropertySourceinstances
-
-
Method Details
-
diff
-
addPropertySource
Add aPropertySourceto this resolver.- Parameters:
propertySource- ThePropertySourceto add- Returns:
- This
PropertySourcePropertyResolver
-
addPropertySource
public PropertySourcePropertyResolver addPropertySource(String name, @Nullable Map<String, ? super Object> values) Add a property source for the given map.- Parameters:
name- The name of the property sourcevalues- The values- Returns:
- This environment
-
containsProperty
- Specified by:
containsPropertyin interfaceio.micronaut.core.value.PropertyResolver
-
containsProperties
- Specified by:
containsPropertiesin interfaceio.micronaut.core.value.PropertyResolver
-
getPropertyEntries
- Specified by:
getPropertyEntriesin interfaceio.micronaut.core.value.PropertyResolver
-
getPropertyEntries
public Collection<String> getPropertyEntries(String name, io.micronaut.core.value.PropertyCatalog propertyCatalog) - Specified by:
getPropertyEntriesin interfaceio.micronaut.core.value.PropertyResolver
-
getPropertyPathMatches
-
getProperties
-
getProperty
-
getAllProperties
public Map<String,Object> getAllProperties(io.micronaut.core.naming.conventions.StringConvention keyConvention, io.micronaut.core.convert.format.MapFormat.MapTransformation transformation) Returns a combined Map of all properties in the catalog.- Parameters:
keyConvention- The map key conventiontransformation- The map format- Returns:
- Map of all properties
-
resolveSubProperties
protected Properties resolveSubProperties(String name, Map<String, io.micronaut.context.env.DefaultPropertyEntry> entries, io.micronaut.core.convert.ArgumentConversionContext<?> conversionContext) - Parameters:
name- The property nameentries- The entriesconversionContext- The conversion context- Returns:
- The subproperties
-
resolveSubMap
protected Map<String,Object> resolveSubMap(String name, Map<String, io.micronaut.context.env.DefaultPropertyEntry> entries, io.micronaut.core.convert.ArgumentConversionContext<?> conversionContext) - Parameters:
name- The property nameentries- The entriesconversionContext- The conversion context- Returns:
- The submap
-
resolveSubMap
protected Map<String,Object> resolveSubMap(String name, Map<String, io.micronaut.context.env.DefaultPropertyEntry> entries, io.micronaut.core.convert.ArgumentConversionContext<?> conversionContext, @Nullable io.micronaut.core.naming.conventions.StringConvention keyConvention, io.micronaut.core.convert.format.MapFormat.MapTransformation transformation) Resolves a submap for the given name and parameters.- Parameters:
name- The nameentries- The entriesconversionContext- The conversion contextkeyConvention- The key convention to usetransformation- The map transformation to apply- Returns:
- The resulting map
-
processPropertySource
protected void processPropertySource(PropertySource properties, PropertySource.PropertyConvention convention) - Parameters:
properties- The property sourceconvention- The property convention
-
resolveEntriesForKey
protected final @Nullable Map<String, io.micronaut.context.env.DefaultPropertyEntry> resolveEntriesForKey(String name, boolean allowCreate, @Nullable io.micronaut.core.value.PropertyCatalog propertyCatalog) - Parameters:
name- The nameallowCreate- Whether allows creationpropertyCatalog- The string convention- Returns:
- The map with the resolved entries for the name
-
resetCaches
protected void resetCaches()Subclasses can override to reset caches. -
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-