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
Direct Known Subclasses:
DefaultEnvironment

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 Details

    • conversionService

      protected final io.micronaut.core.convert.ConversionService conversionService
    • propertyPlaceholderResolver

      protected final PropertyPlaceholderResolver propertyPlaceholderResolver
    • propertySources

      protected final Map<String,PropertySource> propertySources
    • catalog

      protected final Map<String,Object>[] catalog
    • rawCatalog

      protected final Map<String,Object>[] rawCatalog
    • nonGenerated

      protected final Map<String,Object>[] nonGenerated
    • log

      protected org.slf4j.Logger log
  • Constructor Details

    • PropertySourcePropertyResolver

      public PropertySourcePropertyResolver(io.micronaut.core.convert.ConversionService conversionService, boolean logEnabled)
      Creates a new, initially empty, PropertySourcePropertyResolver for the given ConversionService.
      Parameters:
      conversionService - The ConversionService
      logEnabled - flag to enable or disable logger
    • PropertySourcePropertyResolver

      public PropertySourcePropertyResolver(io.micronaut.core.convert.ConversionService conversionService)
      Creates a new, initially empty, PropertySourcePropertyResolver for the given ConversionService.
      Parameters:
      conversionService - The ConversionService
    • PropertySourcePropertyResolver

      public PropertySourcePropertyResolver()
      Creates a new, initially empty, PropertySourcePropertyResolver.
    • PropertySourcePropertyResolver

      public PropertySourcePropertyResolver(PropertySource... propertySources)
      Creates a new PropertySourcePropertyResolver for the given PropertySource instances.
      Parameters:
      propertySources - The PropertySource instances
  • Method Details

    • addPropertySource

      public PropertySourcePropertyResolver addPropertySource(@Nullable @Nullable PropertySource propertySource)
      Add a PropertySource to this resolver.
      Parameters:
      propertySource - The PropertySource to add
      Returns:
      This PropertySourcePropertyResolver
    • addPropertySource

      public PropertySourcePropertyResolver addPropertySource(String name, @Nullable @Nullable Map<String,? super Object> values)
      Add a property source for the given map.
      Parameters:
      name - The name of the property source
      values - The values
      Returns:
      This environment
    • containsProperty

      public boolean containsProperty(@Nullable @Nullable String name)
      Specified by:
      containsProperty in interface io.micronaut.core.value.PropertyResolver
    • containsProperties

      public boolean containsProperties(@Nullable @Nullable String name)
      Specified by:
      containsProperties in interface io.micronaut.core.value.PropertyResolver
    • getPropertyEntries

      @NonNull public @NonNull Collection<String> getPropertyEntries(@NonNull @NonNull String name)
      Specified by:
      getPropertyEntries in interface io.micronaut.core.value.PropertyResolver
    • getPropertyPathMatches

      public Set<List<String>> getPropertyPathMatches(String pathPattern)
      Specified by:
      getPropertyPathMatches in interface io.micronaut.core.value.PropertyResolver
    • getProperties

      @NonNull public @NonNull Map<String,Object> getProperties(String name, io.micronaut.core.naming.conventions.StringConvention keyFormat)
      Specified by:
      getProperties in interface io.micronaut.core.value.PropertyResolver
    • getProperty

      public <T> Optional<T> getProperty(@NonNull @NonNull String name, @NonNull @NonNull io.micronaut.core.convert.ArgumentConversionContext<T> conversionContext)
      Specified by:
      getProperty in interface io.micronaut.core.value.PropertyResolver
    • 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 convention
      transformation - The map format
      Returns:
      Map of all properties
    • resolveSubProperties

      protected Properties resolveSubProperties(String name, Map<String,Object> entries, io.micronaut.core.convert.ArgumentConversionContext<?> conversionContext)
      Parameters:
      name - The property name
      entries - The entries
      conversionContext - The conversion context
      Returns:
      The subproperties
    • resolveSubMap

      protected Map<String,Object> resolveSubMap(String name, Map<String,Object> entries, io.micronaut.core.convert.ArgumentConversionContext<?> conversionContext)
      Parameters:
      name - The property name
      entries - The entries
      conversionContext - The conversion context
      Returns:
      The submap
    • resolveSubMap

      @NonNull protected @NonNull Map<String,Object> resolveSubMap(String name, Map<String,Object> entries, io.micronaut.core.convert.ArgumentConversionContext<?> conversionContext, @Nullable @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 name
      entries - The entries
      conversionContext - The conversion context
      keyConvention - The key convention to use
      transformation - The map transformation to apply
      Returns:
      The resulting map
    • processPropertySource

      protected void processPropertySource(PropertySource properties, PropertySource.PropertyConvention convention)
      Parameters:
      properties - The property source
      convention - The property convention
    • resolveEntriesForKey

      protected Map<String,Object> resolveEntriesForKey(String name, boolean allowCreate, @Nullable @Nullable PropertySourcePropertyResolver.PropertyCatalog propertyCatalog)
      Parameters:
      name - The name
      allowCreate - Whether allows creation
      propertyCatalog - The string convention
      Returns:
      The map with the resolved entries for the name
    • resetCaches

      protected void resetCaches()
      Subclasses can override to reset caches.
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception