类 PropertySourcesUtils


  • public abstract class PropertySourcesUtils
    extends java.lang.Object
    PropertySources Utilities
    从以下版本开始:
    1.0.0
    作者:
    Mercy
    另请参阅:
    PropertySources
    • 方法概要

      所有方法 静态方法 具体方法 
      修饰符和类型 方法 说明
      static void addDefaultProperties​(org.springframework.core.env.ConfigurableEnvironment environment, java.lang.String key, java.lang.Object value, java.lang.Object... others)  
      static boolean containsBootstrapPropertySource​(org.springframework.core.env.ConfigurableEnvironment environment)
      Contains the Bootstrap PropertySource or not
      static boolean containsPropertySource​(org.springframework.core.env.ConfigurableEnvironment environment, java.lang.String propertySourceName)
      Contains the specified PropertySource or not
      static org.springframework.core.env.PropertySource findConfiguredPropertySource​(java.lang.Iterable<org.springframework.core.env.PropertySource<?>> propertySources, java.lang.String propertyName)  
      static org.springframework.core.env.PropertySource findConfiguredPropertySource​(org.springframework.core.env.ConfigurableEnvironment environment, java.lang.String propertyName)  
      static java.lang.String findConfiguredPropertySourceName​(java.lang.Iterable<org.springframework.core.env.PropertySource<?>> propertySources, java.lang.String propertyName)  
      static java.lang.String findConfiguredPropertySourceName​(org.springframework.core.env.ConfigurableEnvironment environment, java.lang.String propertyName)  
      static java.util.Set<java.lang.String> findPropertyNames​(org.springframework.core.env.ConfigurableEnvironment environment, java.util.function.Predicate<java.lang.String> propertyNameFilter)  
      static java.util.Set<java.lang.String> findPropertyNamesByPrefix​(org.springframework.core.env.ConfigurableEnvironment environment, java.lang.String propertyNamePrefix)  
      static java.util.Map<java.lang.String,​java.lang.Object> getDefaultProperties​(org.springframework.core.env.ConfigurableEnvironment environment)
      Get the Map properties from the "default" PropertySource that is the lowest order one of the Spring PropertySources is created if absent
      static java.util.Map<java.lang.String,​java.lang.Object> getDefaultProperties​(org.springframework.core.env.ConfigurableEnvironment environment, boolean createIfAbsent)
      Get the Map properties from the "default" PropertySource that is the lowest order one of the Spring PropertySources is created if specified.
      static org.springframework.core.env.MapPropertySource getDefaultPropertiesPropertySource​(org.springframework.core.env.ConfigurableEnvironment environment)
      Get the "default" PropertySource that is the lowest order one of the Spring PropertySources is created if absent
      static org.springframework.core.env.MapPropertySource getDefaultPropertiesPropertySource​(org.springframework.core.env.ConfigurableEnvironment environment, boolean createIfAbsent)
      Get the "default" PropertySource that is the lowest order one of the Spring PropertySources is created if specified
      static org.springframework.core.env.MapPropertySource getMapPropertySource​(org.springframework.core.env.ConfigurableEnvironment environment, java.lang.String propertySourceName)  
      static org.springframework.core.env.MapPropertySource getMapPropertySource​(org.springframework.core.env.ConfigurableEnvironment environment, java.lang.String propertySourceName, boolean created)  
      static java.util.Map<java.lang.String,​java.lang.Object> getProperties​(org.springframework.core.env.PropertySource propertySource)
      Get the Map as the properties from the specified PropertySource
      static java.lang.String[] getPropertyNames​(org.springframework.core.env.PropertySource propertySource)
      Get the property names as the array from the specified PropertySource instance.
      static <T extends org.springframework.core.env.PropertySource<?>>
      T
      getPropertySource​(org.springframework.core.env.ConfigurableEnvironment environment, java.lang.String propertySourceName, java.lang.Class<T> propertySourceType)  
      static <T extends org.springframework.core.env.PropertySource<?>>
      T
      getPropertySource​(org.springframework.core.env.ConfigurableEnvironment environment, java.lang.String propertySourceName, java.lang.Class<T> propertySourceType, java.util.function.Supplier<T> propertySourceSupplierIfAbsent)  
      static java.util.Map<java.lang.String,​java.lang.Object> getSubProperties​(java.lang.Iterable<org.springframework.core.env.PropertySource<?>> propertySources, java.lang.String prefix)
      Get Sub Properties
      static java.util.Map<java.lang.String,​java.lang.Object> getSubProperties​(org.springframework.core.env.ConfigurableEnvironment environment, java.lang.String prefix)
      Get Sub Properties
      static java.util.Map<java.lang.String,​java.lang.Object> getSubProperties​(org.springframework.core.env.PropertySources propertySources, java.lang.String prefix)
      Get prefixed Properties
      static java.util.Map<java.lang.String,​java.lang.Object> getSubProperties​(org.springframework.core.env.PropertySources propertySources, org.springframework.core.env.PropertyResolver propertyResolver, java.lang.String prefix)
      Get prefixed Properties
      static java.lang.String normalizePrefix​(java.lang.String prefix)
      Normalize the prefix
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 字段详细资料

      • DEFAULT_PROPERTIES_PROPERTY_SOURCE_NAME

        public static final java.lang.String DEFAULT_PROPERTIES_PROPERTY_SOURCE_NAME
        The PropertySource name of Spring Boot default poperties
        另请参阅:
        org.springframework.boot.DefaultPropertiesPropertySource#addOrMerge(Map, MutablePropertySources), org.springframework.boot.DefaultPropertiesPropertySource#NAME, 常量字段值
      • BOOTSTRAP_PROPERTY_SOURCE_NAME

        public static final java.lang.String BOOTSTRAP_PROPERTY_SOURCE_NAME
        The PropertySource name of Spring Cloud Bootstrap context
        另请参阅:
        org.springframework.cloud.bootstrap.BootstrapApplicationListener#BOOTSTRAP_PROPERTY_SOURCE_NAME, 常量字段值
    • 构造器详细资料

      • PropertySourcesUtils

        public PropertySourcesUtils()
    • 方法详细资料

      • getPropertySource

        public static <T extends org.springframework.core.env.PropertySource<?>> T getPropertySource​(org.springframework.core.env.ConfigurableEnvironment environment,
                                                                                                     java.lang.String propertySourceName,
                                                                                                     java.lang.Class<T> propertySourceType)
      • getPropertySource

        public static <T extends org.springframework.core.env.PropertySource<?>> T getPropertySource​(org.springframework.core.env.ConfigurableEnvironment environment,
                                                                                                     java.lang.String propertySourceName,
                                                                                                     java.lang.Class<T> propertySourceType,
                                                                                                     java.util.function.Supplier<T> propertySourceSupplierIfAbsent)
      • getMapPropertySource

        public static org.springframework.core.env.MapPropertySource getMapPropertySource​(org.springframework.core.env.ConfigurableEnvironment environment,
                                                                                          java.lang.String propertySourceName)
      • getMapPropertySource

        public static org.springframework.core.env.MapPropertySource getMapPropertySource​(org.springframework.core.env.ConfigurableEnvironment environment,
                                                                                          java.lang.String propertySourceName,
                                                                                          boolean created)
      • findConfiguredPropertySource

        public static org.springframework.core.env.PropertySource findConfiguredPropertySource​(org.springframework.core.env.ConfigurableEnvironment environment,
                                                                                               java.lang.String propertyName)
      • findConfiguredPropertySource

        public static org.springframework.core.env.PropertySource findConfiguredPropertySource​(java.lang.Iterable<org.springframework.core.env.PropertySource<?>> propertySources,
                                                                                               java.lang.String propertyName)
      • findConfiguredPropertySourceName

        public static java.lang.String findConfiguredPropertySourceName​(org.springframework.core.env.ConfigurableEnvironment environment,
                                                                        java.lang.String propertyName)
      • findConfiguredPropertySourceName

        public static java.lang.String findConfiguredPropertySourceName​(java.lang.Iterable<org.springframework.core.env.PropertySource<?>> propertySources,
                                                                        java.lang.String propertyName)
      • findPropertyNamesByPrefix

        public static java.util.Set<java.lang.String> findPropertyNamesByPrefix​(org.springframework.core.env.ConfigurableEnvironment environment,
                                                                                java.lang.String propertyNamePrefix)
      • findPropertyNames

        public static java.util.Set<java.lang.String> findPropertyNames​(org.springframework.core.env.ConfigurableEnvironment environment,
                                                                        java.util.function.Predicate<java.lang.String> propertyNameFilter)
      • getSubProperties

        public static java.util.Map<java.lang.String,​java.lang.Object> getSubProperties​(java.lang.Iterable<org.springframework.core.env.PropertySource<?>> propertySources,
                                                                                              java.lang.String prefix)
        Get Sub Properties
        参数:
        propertySources - PropertySource Iterable
        prefix - the prefix of property name
        返回:
        Map
        另请参阅:
        Properties
      • getSubProperties

        public static java.util.Map<java.lang.String,​java.lang.Object> getSubProperties​(org.springframework.core.env.ConfigurableEnvironment environment,
                                                                                              java.lang.String prefix)
        Get Sub Properties
        参数:
        environment - ConfigurableEnvironment
        prefix - the prefix of property name
        返回:
        Map
        另请参阅:
        Properties
      • normalizePrefix

        public static java.lang.String normalizePrefix​(java.lang.String prefix)
        Normalize the prefix
        参数:
        prefix - the prefix
        返回:
        the prefix
      • getSubProperties

        public static java.util.Map<java.lang.String,​java.lang.Object> getSubProperties​(org.springframework.core.env.PropertySources propertySources,
                                                                                              java.lang.String prefix)
        Get prefixed Properties
        参数:
        propertySources - PropertySources
        prefix - the prefix of property name
        返回:
        Map
        从以下版本开始:
        1.0.0
        另请参阅:
        Properties
      • getSubProperties

        public static java.util.Map<java.lang.String,​java.lang.Object> getSubProperties​(org.springframework.core.env.PropertySources propertySources,
                                                                                              org.springframework.core.env.PropertyResolver propertyResolver,
                                                                                              java.lang.String prefix)
        Get prefixed Properties
        参数:
        propertySources - PropertySources
        propertyResolver - PropertyResolver to resolve the placeholder if present
        prefix - the prefix of property name
        返回:
        Map
        从以下版本开始:
        1.0.0
        另请参阅:
        Properties
      • getPropertyNames

        @Nonnull
        public static java.lang.String[] getPropertyNames​(org.springframework.core.env.PropertySource propertySource)
        Get the property names as the array from the specified PropertySource instance.
        参数:
        propertySource - PropertySource instance
        返回:
        non-null
        从以下版本开始:
        1.0.0
      • getProperties

        @Nonnull
        public static java.util.Map<java.lang.String,​java.lang.Object> getProperties​(org.springframework.core.env.PropertySource propertySource)
        Get the Map as the properties from the specified PropertySource
        参数:
        propertySource - the specified PropertySource
        返回:
        non-null read-only Map
      • addDefaultProperties

        public static void addDefaultProperties​(org.springframework.core.env.ConfigurableEnvironment environment,
                                                java.lang.String key,
                                                java.lang.Object value,
                                                java.lang.Object... others)
      • getDefaultProperties

        public static java.util.Map<java.lang.String,​java.lang.Object> getDefaultProperties​(org.springframework.core.env.ConfigurableEnvironment environment)
        Get the Map properties from the "default" PropertySource that is the lowest order one of the Spring PropertySources is created if absent
        参数:
        environment - ConfigurableEnvironment
        返回:
        non-null mutable Map
        另请参阅:
        DEFAULT_PROPERTIES_PROPERTY_SOURCE_NAME, getDefaultProperties(ConfigurableEnvironment, boolean)
      • getDefaultProperties

        public static java.util.Map<java.lang.String,​java.lang.Object> getDefaultProperties​(org.springframework.core.env.ConfigurableEnvironment environment,
                                                                                                  boolean createIfAbsent)
        Get the Map properties from the "default" PropertySource that is the lowest order one of the Spring PropertySources is created if specified.
        参数:
        environment - ConfigurableEnvironment
        createIfAbsent - true indicates the "default" PropertySource will be created if absent
        返回:
        non-null mutable Map
        另请参阅:
        DEFAULT_PROPERTIES_PROPERTY_SOURCE_NAME, getDefaultProperties(ConfigurableEnvironment, boolean)
      • getDefaultPropertiesPropertySource

        public static org.springframework.core.env.MapPropertySource getDefaultPropertiesPropertySource​(org.springframework.core.env.ConfigurableEnvironment environment)
        Get the "default" PropertySource that is the lowest order one of the Spring PropertySources is created if absent
        参数:
        environment - ConfigurableEnvironment
        返回:
        non-null MapPropertySource
      • getDefaultPropertiesPropertySource

        public static org.springframework.core.env.MapPropertySource getDefaultPropertiesPropertySource​(org.springframework.core.env.ConfigurableEnvironment environment,
                                                                                                        boolean createIfAbsent)
        Get the "default" PropertySource that is the lowest order one of the Spring PropertySources is created if specified
        参数:
        environment - ConfigurableEnvironment
        createIfAbsent - true indicates the "default" PropertySource will be created if absent
        返回:
        non-null MapPropertySource
      • containsPropertySource

        public static boolean containsPropertySource​(org.springframework.core.env.ConfigurableEnvironment environment,
                                                     java.lang.String propertySourceName)
        Contains the specified PropertySource or not
        参数:
        environment - ConfigurableEnvironment
        propertySourceName - the PropertySource name
        返回:
        if contains, return true, otherwise false
      • containsBootstrapPropertySource

        public static boolean containsBootstrapPropertySource​(org.springframework.core.env.ConfigurableEnvironment environment)
        Contains the Bootstrap PropertySource or not
        参数:
        environment - ConfigurableEnvironment
        返回:
        if contains, return true, otherwise false