Class PropertyValuesUtils

java.lang.Object
io.microsphere.spring.beans.PropertyValuesUtils
All Implemented Interfaces:
io.microsphere.util.Utils

public abstract class PropertyValuesUtils extends Object implements io.microsphere.util.Utils
PropertyValues Utilities
Since:
1.0.0
Author:
Mercy
See Also:
  • PropertyValues
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.springframework.beans.PropertyValues
    getSubPropertyValues(org.springframework.core.env.ConfigurableEnvironment environment, String prefix)
    Extracts a subset of properties from the given ConfigurableEnvironment based on the specified prefix, and returns them as a PropertyValues instance.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 given ConfigurableEnvironment based on the specified prefix, and returns them as a PropertyValues 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 - the ConfigurableEnvironment to extract properties from
      prefix - 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