Package io.microsphere.spring.beans
Class PropertyValuesUtils
- java.lang.Object
-
- io.microsphere.spring.beans.PropertyValuesUtils
-
- All Implemented Interfaces:
io.microsphere.util.Utils
public abstract class PropertyValuesUtils extends java.lang.Object implements io.microsphere.util.Utils
PropertyValues
Utilities- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
PropertyValues
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.springframework.beans.PropertyValues
getSubPropertyValues(org.springframework.core.env.ConfigurableEnvironment environment, java.lang.String prefix)
Extracts a subset of properties from the givenConfigurableEnvironment
based on the specified prefix, and returns them as aPropertyValues
instance.
-
-
-
Method Detail
-
getSubPropertyValues
public static org.springframework.beans.PropertyValues getSubPropertyValues(org.springframework.core.env.ConfigurableEnvironment environment, java.lang.String prefix)
Extracts a subset of properties from the givenConfigurableEnvironment
based on the specified prefix, and returns them as aPropertyValues
instance.This method is useful when you need to isolate a group of related properties, such as those belonging to a specific configuration section.
Example Usage
ConfigurableEnvironment environment = context.getEnvironment(); PropertyValues databaseProperties = PropertyValuesUtils.getSubPropertyValues(environment, "database."); // This will include all properties under "database.*"
- Parameters:
environment
- theConfigurableEnvironment
to extract properties fromprefix
- the prefix used to filter properties (e.g., "database.")- Returns:
- a
PropertyValues
instance containing the filtered properties - Throws:
java.lang.IllegalArgumentException
- if the provided environment is null
-
-