Class PropertySourceUtils


  • public final class PropertySourceUtils
    extends java.lang.Object
    Utilities for working with Spring PropertySource.
    Since:
    4.0.0
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Map<java.lang.String,​java.lang.String> createPropertiesSnapshot​(org.springframework.core.env.Environment environment, java.lang.String prefix)
      Takes a snapshot of the properties that match a given prefix.
      static org.springframework.core.env.PropertySource<?> loadYamlPropertySource​(java.lang.String propertySourceName, org.springframework.core.io.Resource resource)
      Load a YAML PropertySource from the given resource.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • loadYamlPropertySource

        public static org.springframework.core.env.PropertySource<?> loadYamlPropertySource​(java.lang.String propertySourceName,
                                                                                            org.springframework.core.io.Resource resource)
        Load a YAML PropertySource from the given resource.
        Parameters:
        propertySourceName - The name of the this property source
        resource - The resource. Must exist and be YAML.
        Returns:
        A PropertySource representing this set of properties
      • createPropertiesSnapshot

        public static java.util.Map<java.lang.String,​java.lang.String> createPropertiesSnapshot​(org.springframework.core.env.Environment environment,
                                                                                                      java.lang.String prefix)
        Takes a snapshot of the properties that match a given prefix. The prefix is stripped from the property name. Properties with empty and null values are not included.
        Parameters:
        environment - the environment
        prefix - the prefix to match
        Returns:
        an immutable map of property name and property value in string form