Class DefaultPropertiesPropertySource

java.lang.Object
org.springframework.core.env.PropertySource<T>
org.springframework.core.env.EnumerablePropertySource<Map<String,Object>>
org.springframework.core.env.MapPropertySource
org.springframework.boot.DefaultPropertiesPropertySource

public class DefaultPropertiesPropertySource extends org.springframework.core.env.MapPropertySource
MapPropertySource containing default properties contributed directly to a SpringApplication. By convention, the DefaultPropertiesPropertySource is always the last property source in the Environment.
Since:
2.4.0
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.springframework.core.env.PropertySource

    org.springframework.core.env.PropertySource.StubPropertySource
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The name of the 'default properties' property source.

    Fields inherited from class org.springframework.core.env.PropertySource

    logger, name, source
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new DefaultPropertiesPropertySource with the given Map source.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addOrMerge(Map<String,Object> source, org.springframework.core.env.MutablePropertySources sources)
    Add a new DefaultPropertiesPropertySource or merge with an existing one.
    static boolean
    hasMatchingName(org.springframework.core.env.PropertySource<?> propertySource)
    Return true if the given source is named 'defaultProperties'.
    static void
    Create a new DefaultPropertiesPropertySource instance if the provided source is not empty.
    static void
    moveToEnd(org.springframework.core.env.ConfigurableEnvironment environment)
    Move the 'defaultProperties' property source so that it's the last source in the given ConfigurableEnvironment.
    static void
    moveToEnd(org.springframework.core.env.MutablePropertySources propertySources)
    Move the 'defaultProperties' property source so that it's the last source in the given MutablePropertySources.

    Methods inherited from class org.springframework.core.env.MapPropertySource

    containsProperty, getProperty, getPropertyNames

    Methods inherited from class org.springframework.core.env.PropertySource

    equals, getName, getSource, hashCode, named, toString

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • hasMatchingName

      public static boolean hasMatchingName(org.springframework.core.env.PropertySource<?> propertySource)
      Return true if the given source is named 'defaultProperties'.
      Parameters:
      propertySource - the property source to check
      Returns:
      true if the name matches
    • ifNotEmpty

      public static void ifNotEmpty(Map<String,Object> source, Consumer<DefaultPropertiesPropertySource> action)
      Create a new DefaultPropertiesPropertySource instance if the provided source is not empty.
      Parameters:
      source - the Map source
      action - the action used to consume the DefaultPropertiesPropertySource
    • addOrMerge

      public static void addOrMerge(Map<String,Object> source, org.springframework.core.env.MutablePropertySources sources)
      Add a new DefaultPropertiesPropertySource or merge with an existing one.
      Parameters:
      source - the Map source
      sources - the existing sources
      Since:
      2.4.4
    • moveToEnd

      public static void moveToEnd(org.springframework.core.env.ConfigurableEnvironment environment)
      Move the 'defaultProperties' property source so that it's the last source in the given ConfigurableEnvironment.
      Parameters:
      environment - the environment to update
    • moveToEnd

      public static void moveToEnd(org.springframework.core.env.MutablePropertySources propertySources)
      Move the 'defaultProperties' property source so that it's the last source in the given MutablePropertySources.
      Parameters:
      propertySources - the property sources to update