Class PropertySourcePropertyResolver

  • All Implemented Interfaces:
    io.micronaut.core.value.PropertyResolver, io.micronaut.core.value.ValueResolver<java.lang.String>, java.lang.AutoCloseable
    Direct Known Subclasses:
    DefaultEnvironment

    public class PropertySourcePropertyResolver
    extends java.lang.Object
    implements io.micronaut.core.value.PropertyResolver, java.lang.AutoCloseable

    A PropertyResolver that resolves from one or many PropertySource instances.

    Since:
    1.0
    • Field Detail

      • conversionService

        protected final io.micronaut.core.convert.ConversionService<?> conversionService
      • propertySources

        protected final java.util.Map<java.lang.String,​PropertySource> propertySources
      • catalog

        protected final java.util.Map<java.lang.String,​java.lang.Object>[] catalog
      • rawCatalog

        protected final java.util.Map<java.lang.String,​java.lang.Object>[] rawCatalog
      • nonGenerated

        protected final java.util.Map<java.lang.String,​java.lang.Object>[] nonGenerated
      • log

        protected org.slf4j.Logger log
    • Constructor Detail

      • 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 - 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
    • Method Detail

      • addPropertySource

        public PropertySourcePropertyResolver addPropertySource​(java.lang.String name,
                                                                @Nullable
                                                                java.util.Map<java.lang.String,​? super java.lang.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
                                        java.lang.String name)
        Specified by:
        containsProperty in interface io.micronaut.core.value.PropertyResolver
      • containsProperties

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

        @NonNull
        public java.util.Collection<java.lang.String> getPropertyEntries​(@NonNull
                                                                         java.lang.String name)
        Specified by:
        getPropertyEntries in interface io.micronaut.core.value.PropertyResolver
      • getProperties

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

        public <T> java.util.Optional<T> getProperty​(@NonNull
                                                     java.lang.String name,
                                                     @NonNull
                                                     io.micronaut.core.convert.ArgumentConversionContext<T> conversionContext)
        Specified by:
        getProperty in interface io.micronaut.core.value.PropertyResolver
      • getAllProperties

        public java.util.Map<java.lang.String,​java.lang.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 java.util.Properties resolveSubProperties​(java.lang.String name,
                                                            java.util.Map<java.lang.String,​java.lang.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 java.util.Map<java.lang.String,​java.lang.Object> resolveSubMap​(java.lang.String name,
                                                                                       java.util.Map<java.lang.String,​java.lang.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 java.util.Map<java.lang.String,​java.lang.Object> resolveSubMap​(java.lang.String name,
                                                                                       java.util.Map<java.lang.String,​java.lang.Object> 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 name
        entries - The entries
        conversionContext - The conversion context
        keyConvention - The key convention to use
        transformation - The map transformation to apply
        Returns:
        The resulting map
      • resolveEntriesForKey

        protected java.util.Map<java.lang.String,​java.lang.Object> resolveEntriesForKey​(java.lang.String name,
                                                                                              boolean allowCreate)
        Parameters:
        name - The name
        allowCreate - Whether allows creation
        Returns:
        The map with the resolved entries for the name
      • resolveEntriesForKey

        protected java.util.Map<java.lang.String,​java.lang.Object> resolveEntriesForKey​(java.lang.String name,
                                                                                              boolean allowCreate,
                                                                                              @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 java.lang.Exception
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception
      • isLogEnabled

        @Deprecated
        public boolean isLogEnabled()
        Deprecated.
        don't need to have this method
        Return logEnabled value.
        Returns:
        is log enabled
        Since:
        3.9.0
      • setLogEnabled

        @Deprecated
        public void setLogEnabled​(boolean logEnabled)
        Deprecated.
        set logEnabled value by constructor
        Setter for logEnabled.
        Parameters:
        logEnabled - is log enabled
        Since:
        3.9.0