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.BaseUtilsEnvironmentUtilities class- Since:
- 1.0.0
- Author:
- Mercy
-
-
Constructor Summary
Constructors Constructor Description EnvironmentUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.springframework.core.env.ConfigurableEnvironmentasConfigurableEnvironment(org.springframework.core.env.Environment environment)CastEnvironmenttoConfigurableEnvironmentstatic org.springframework.core.convert.ConversionServicegetConversionService(org.springframework.core.env.Environment environment)Get theConversionServicefrom the specifiedEnvironmentstatic 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 specifiedEnvironmentand property namesstatic 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 specifiedEnvironmentand property namesstatic 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 specifiedEnvironmentand property namesstatic java.util.List<java.lang.String>resolveCommaDelimitedValueToList(org.springframework.core.env.Environment environment, java.lang.String commaDelimitedValue)Resolve the comma delimited value toListstatic <T> TresolvePlaceholders(org.springframework.core.env.Environment environment, java.lang.String propertyValue, java.lang.Class<T> targetType)Resolve the placeholdersstatic <T> TresolvePlaceholders(org.springframework.core.env.Environment environment, java.lang.String propertyValue, java.lang.Class<T> targetType, T defaultValue)Resolve the placeholders
-
-
-
Method Detail
-
asConfigurableEnvironment
public static org.springframework.core.env.ConfigurableEnvironment asConfigurableEnvironment(org.springframework.core.env.Environment environment) throws java.lang.IllegalArgumentExceptionCastEnvironmenttoConfigurableEnvironment- Parameters:
environment-Environment- Returns:
ConfigurableEnvironment- Throws:
java.lang.IllegalArgumentException- Ifenvironmentargument is not an instance ofConfigurableEnvironment
-
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 specifiedEnvironmentand property names- Parameters:
environment-EnvironmentpropertyNames- 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 specifiedEnvironmentand property names- Parameters:
environment-EnvironmentpropertyNames- 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 specifiedEnvironmentand property names- Parameters:
environment-EnvironmentpropertyNames- the property names- Returns:
- non-null
-
getConversionService
@Nullable public static org.springframework.core.convert.ConversionService getConversionService(org.springframework.core.env.Environment environment)
Get theConversionServicefrom the specifiedEnvironment- Parameters:
environment-Environment- Returns:
ConversionServiceif found, ornull
-
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 toList- Parameters:
environment-EnvironmentcommaDelimitedValue- 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-EnvironmentpropertyValue- the property valuetargetType- 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-EnvironmentpropertyValue- the property valuetargetType- the target typedefaultValue- the default value- Returns:
- the resolved value
-
-