Package io.microsphere.spring.core.env
Class EnvironmentUtils
java.lang.Object
io.microsphere.util.BaseUtils
io.microsphere.spring.core.env.EnvironmentUtils
public abstract class EnvironmentUtils
extends io.microsphere.util.BaseUtils
Environment
Utilities class- Since:
- 1.0.0
- Author:
- Mercy
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.springframework.core.env.ConfigurableEnvironment
asConfigurableEnvironment
(org.springframework.core.env.Environment environment) CastEnvironment
toConfigurableEnvironment
static org.springframework.core.convert.ConversionService
getConversionService
(org.springframework.core.env.Environment environment) Get theConversionService
from the specifiedEnvironment
getProperties
(org.springframework.core.env.Environment environment, Iterable<String> propertyNames) Get the properties from the specifiedEnvironment
and property namesgetProperties
(org.springframework.core.env.Environment environment, String... propertyNames) Get the properties from the specifiedEnvironment
and property namesgetProperties
(org.springframework.core.env.Environment environment, Set<String> propertyNames) Get the properties from the specifiedEnvironment
and property namesresolveCommaDelimitedValueToList
(org.springframework.core.env.Environment environment, String commaDelimitedValue) Resolve the comma delimited value toList
static <T> T
resolvePlaceholders
(org.springframework.core.env.Environment environment, String propertyValue, Class<T> targetType) Resolve the placeholdersstatic <T> T
resolvePlaceholders
(org.springframework.core.env.Environment environment, String propertyValue, Class<T> targetType, T defaultValue) Resolve the placeholders
-
Constructor Details
-
EnvironmentUtils
public EnvironmentUtils()
-
-
Method Details
-
asConfigurableEnvironment
public static org.springframework.core.env.ConfigurableEnvironment asConfigurableEnvironment(org.springframework.core.env.Environment environment) throws IllegalArgumentException CastEnvironment
toConfigurableEnvironment
- Parameters:
environment
-Environment
- Returns:
ConfigurableEnvironment
- Throws:
IllegalArgumentException
- Ifenvironment
argument is not an instance ofConfigurableEnvironment
-
getProperties
@Nonnull public static Map<String,String> getProperties(org.springframework.core.env.Environment environment, String... propertyNames) Get the properties from the specifiedEnvironment
and property names- Parameters:
environment
-Environment
propertyNames
- the property names- Returns:
- non-null
-
getProperties
@Nonnull public static Map<String,String> getProperties(org.springframework.core.env.Environment environment, Iterable<String> propertyNames) Get the properties from the specifiedEnvironment
and property names- Parameters:
environment
-Environment
propertyNames
- the property names- Returns:
- non-null
-
getProperties
@Nonnull public static Map<String,String> getProperties(org.springframework.core.env.Environment environment, Set<String> propertyNames) Get the properties from the specifiedEnvironment
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 theConversionService
from the specifiedEnvironment
- Parameters:
environment
-Environment
- Returns:
ConversionService
if found, ornull
-
resolveCommaDelimitedValueToList
@Nonnull public static List<String> resolveCommaDelimitedValueToList(org.springframework.core.env.Environment environment, String commaDelimitedValue) Resolve the comma delimited value toList
- Parameters:
environment
-Environment
commaDelimitedValue
- the comma delimited value- Returns:
- non-null
-
resolvePlaceholders
@Nullable public static <T> T resolvePlaceholders(org.springframework.core.env.Environment environment, String propertyValue, Class<T> targetType) Resolve the placeholders- Type Parameters:
T
- the target type- Parameters:
environment
-Environment
propertyValue
- the property valuetargetType
- the target type- Returns:
- the resolved value
-
resolvePlaceholders
@Nullable public static <T> T resolvePlaceholders(org.springframework.core.env.Environment environment, String propertyValue, Class<T> targetType, T defaultValue) Resolve the placeholders- Type Parameters:
T
- the target type- Parameters:
environment
-Environment
propertyValue
- the property valuetargetType
- the target typedefaultValue
- the default value- Returns:
- the resolved value
-