Class EnvironmentUtils

  • All Implemented Interfaces:
    io.microsphere.util.Utils

    public abstract class EnvironmentUtils
    extends java.lang.Object
    implements io.microsphere.util.Utils
    Environment Utilities class
    Since:
    1.0.0
    Author:
    Mercy
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.springframework.core.env.ConfigurableEnvironment asConfigurableEnvironment​(org.springframework.core.env.Environment environment)
      Cast Environment to ConfigurableEnvironment
      static org.springframework.core.convert.ConversionService getConversionService​(org.springframework.core.env.Environment environment)
      Get the ConversionService from the specified Environment
      static java.util.Map<java.lang.String,​java.lang.String> getProperties​(org.springframework.core.env.Environment environment, java.lang.Iterable<java.lang.String> propertyNames)
      Get the properties from the specified Environment and property names
      static java.util.Map<java.lang.String,​java.lang.String> getProperties​(org.springframework.core.env.Environment environment, java.lang.String... propertyNames)
      Get the properties from the specified Environment and property names
      static java.util.Map<java.lang.String,​java.lang.String> getProperties​(org.springframework.core.env.Environment environment, java.util.Set<java.lang.String> propertyNames)
      Get the properties from the specified Environment and property names
      static java.util.List<java.lang.String> resolveCommaDelimitedValueToList​(org.springframework.core.env.Environment environment, java.lang.String commaDelimitedValue)
      Resolve the comma delimited value to List
      static <T> T resolvePlaceholders​(org.springframework.core.env.Environment environment, java.lang.String propertyValue, java.lang.Class<T> targetType)
      Resolve the placeholders
      static <T> T resolvePlaceholders​(org.springframework.core.env.Environment environment, java.lang.String propertyValue, java.lang.Class<T> targetType, T defaultValue)
      Resolve the placeholders
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • asConfigurableEnvironment

        public static org.springframework.core.env.ConfigurableEnvironment asConfigurableEnvironment​(org.springframework.core.env.Environment environment)
                                                                                              throws java.lang.IllegalArgumentException
        Cast Environment to ConfigurableEnvironment
        Parameters:
        environment - Environment
        Returns:
        ConfigurableEnvironment
        Throws:
        java.lang.IllegalArgumentException - If environment argument is not an instance of ConfigurableEnvironment
      • getProperties

        @Nonnull
        public static java.util.Map<java.lang.String,​java.lang.String> getProperties​(org.springframework.core.env.Environment environment,
                                                                                           java.lang.String... propertyNames)
        Get the properties from the specified Environment and property names
        Parameters:
        environment - Environment
        propertyNames - the property names
        Returns:
        non-null
      • getProperties

        @Nonnull
        public static java.util.Map<java.lang.String,​java.lang.String> getProperties​(org.springframework.core.env.Environment environment,
                                                                                           java.lang.Iterable<java.lang.String> propertyNames)
        Get the properties from the specified Environment and property names
        Parameters:
        environment - Environment
        propertyNames - the property names
        Returns:
        non-null
      • getProperties

        @Nonnull
        public static java.util.Map<java.lang.String,​java.lang.String> getProperties​(org.springframework.core.env.Environment environment,
                                                                                           java.util.Set<java.lang.String> propertyNames)
        Get the properties from the specified Environment and property names
        Parameters:
        environment - Environment
        propertyNames - the property names
        Returns:
        non-null
      • getConversionService

        @Nullable
        public static org.springframework.core.convert.ConversionService getConversionService​(org.springframework.core.env.Environment environment)
        Get the ConversionService from the specified Environment
        Parameters:
        environment - Environment
        Returns:
        ConversionService if found, or null
      • resolveCommaDelimitedValueToList

        @Nonnull
        public static java.util.List<java.lang.String> resolveCommaDelimitedValueToList​(org.springframework.core.env.Environment environment,
                                                                                        java.lang.String commaDelimitedValue)
        Resolve the comma delimited value to List
        Parameters:
        environment - Environment
        commaDelimitedValue - the comma delimited value
        Returns:
        non-null
      • resolvePlaceholders

        @Nullable
        public static <T> T resolvePlaceholders​(org.springframework.core.env.Environment environment,
                                                java.lang.String propertyValue,
                                                java.lang.Class<T> targetType)
        Resolve the placeholders
        Type Parameters:
        T - the target type
        Parameters:
        environment - Environment
        propertyValue - the property value
        targetType - the target type
        Returns:
        the resolved value
      • resolvePlaceholders

        @Nullable
        public static <T> T resolvePlaceholders​(org.springframework.core.env.Environment environment,
                                                java.lang.String propertyValue,
                                                java.lang.Class<T> targetType,
                                                T defaultValue)
        Resolve the placeholders
        Type Parameters:
        T - the target type
        Parameters:
        environment - Environment
        propertyValue - the property value
        targetType - the target type
        defaultValue - the default value
        Returns:
        the resolved value