Package org.springframework.boot
Class 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
Modifier and TypeFieldDescriptionstatic final String
The name of the 'default properties' property source.Fields inherited from class org.springframework.core.env.PropertySource
logger, name, source
-
Constructor Summary
ConstructorDescriptionDefaultPropertiesPropertySource
(Map<String, Object> source) Create a newDefaultPropertiesPropertySource
with the givenMap
source. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addOrMerge
(Map<String, Object> source, org.springframework.core.env.MutablePropertySources sources) Add a newDefaultPropertiesPropertySource
or merge with an existing one.static boolean
hasMatchingName
(org.springframework.core.env.PropertySource<?> propertySource) Returntrue
if the given source is named 'defaultProperties'.static void
ifNotEmpty
(Map<String, Object> source, Consumer<DefaultPropertiesPropertySource> action) Create a newDefaultPropertiesPropertySource
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 givenConfigurableEnvironment
.static void
moveToEnd
(org.springframework.core.env.MutablePropertySources propertySources) Move the 'defaultProperties' property source so that it's the last source in the givenMutablePropertySources
.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
-
Field Details
-
NAME
The name of the 'default properties' property source.- See Also:
-
-
Constructor Details
-
DefaultPropertiesPropertySource
Create a newDefaultPropertiesPropertySource
with the givenMap
source.- Parameters:
source
- the source map
-
-
Method Details
-
hasMatchingName
public static boolean hasMatchingName(org.springframework.core.env.PropertySource<?> propertySource) Returntrue
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 newDefaultPropertiesPropertySource
instance if the provided source is not empty.- Parameters:
source
- theMap
sourceaction
- the action used to consume theDefaultPropertiesPropertySource
-
addOrMerge
public static void addOrMerge(Map<String, Object> source, org.springframework.core.env.MutablePropertySources sources) Add a newDefaultPropertiesPropertySource
or merge with an existing one.- Parameters:
source
- theMap
sourcesources
- 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 givenConfigurableEnvironment
.- 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 givenMutablePropertySources
.- Parameters:
propertySources
- the property sources to update
-