Package io.microsphere.spring.beans
Class PropertyValuesUtils
java.lang.Object
io.microsphere.spring.beans.PropertyValuesUtils
- All Implemented Interfaces:
io.microsphere.util.Utils
PropertyValues
Utilities- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
-
PropertyValues
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.springframework.beans.PropertyValues
getSubPropertyValues
(org.springframework.core.env.ConfigurableEnvironment environment, String prefix) Extracts a subset of properties from the givenConfigurableEnvironment
based on the specified prefix, and returns them as aPropertyValues
instance.
-
Method Details
-
getSubPropertyValues
public static org.springframework.beans.PropertyValues getSubPropertyValues(org.springframework.core.env.ConfigurableEnvironment environment, 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:
IllegalArgumentException
- if the provided environment is null
-