Class MutablePropertySources
java.lang.Object
org.springframework.core.env.MutablePropertySources
- All Implemented Interfaces:
- Iterable<PropertySource<?>>, PropertySources
The default implementation of the 
PropertySources interface.
Allows manipulation of contained property sources and provides a constructor
for copying an existing PropertySources instance.
Where precedence is mentioned in methods such as addFirst(PropertySource)
and addLast(PropertySource), this is with regard to the order in which property sources
will be searched when resolving a given property with a PropertyResolver.
- Since:
- 3.1
- Author:
- Chris Beams, Juergen Hoeller
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a newMutablePropertySourcesobject.MutablePropertySources(PropertySources propertySources) Create a newMutablePropertySourcesfrom the given propertySources object, preserving the original order of containedPropertySourceobjects.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddAfter(String relativePropertySourceName, PropertySource<?> propertySource) Add the given property source object with precedence immediately lower than the named relative property source.voidaddBefore(String relativePropertySourceName, PropertySource<?> propertySource) Add the given property source object with precedence immediately higher than the named relative property source.voidaddFirst(PropertySource<?> propertySource) Add the given property source object with the highest precedence.voidaddLast(PropertySource<?> propertySource) Add the given property source object with the lowest precedence.protected voidassertLegalRelativeAddition(String relativePropertySourceName, PropertySource<?> propertySource) Ensure that the given property source is not being added relative to itself.booleanReturn whether a property source with the given name is contained.Return the property source with the given name,nullif not found.iterator()intprecedenceOf(PropertySource<?> propertySource) Return the precedence of the given property source,-1if not found.Remove and return the property source with the given name,nullif not found.protected voidremoveIfPresent(PropertySource<?> propertySource) Remove the given property source if it is present.voidreplace(String name, PropertySource<?> propertySource) Replace the property source with the given name with the given property source object.intsize()Return the number ofPropertySourceobjects contained.Stream<PropertySource<?>> stream()Return a sequentialStreamcontaining the property sources.toString()
- 
Constructor Details- 
MutablePropertySourcespublic MutablePropertySources()Create a newMutablePropertySourcesobject.
- 
MutablePropertySourcesCreate a newMutablePropertySourcesfrom the given propertySources object, preserving the original order of containedPropertySourceobjects.
 
- 
- 
Method Details- 
iterator- Specified by:
- iteratorin interface- Iterable<PropertySource<?>>
 
- 
spliterator- Specified by:
- spliteratorin interface- Iterable<PropertySource<?>>
 
- 
streamDescription copied from interface:PropertySourcesReturn a sequentialStreamcontaining the property sources.- Specified by:
- streamin interface- PropertySources
 
- 
containsDescription copied from interface:PropertySourcesReturn whether a property source with the given name is contained.- Specified by:
- containsin interface- PropertySources
- Parameters:
- name- the name of the property source to find
 
- 
getDescription copied from interface:PropertySourcesReturn the property source with the given name,nullif not found.- Specified by:
- getin interface- PropertySources
- Parameters:
- name- the name of the property source to find
 
- 
addFirstAdd the given property source object with the highest precedence.
- 
addLastAdd the given property source object with the lowest precedence.
- 
addBeforeAdd the given property source object with precedence immediately higher than the named relative property source.
- 
addAfterAdd the given property source object with precedence immediately lower than the named relative property source.
- 
precedenceOfReturn the precedence of the given property source,-1if not found.
- 
removeRemove and return the property source with the given name,nullif not found.- Parameters:
- name- the name of the property source to find and remove
 
- 
replaceReplace the property source with the given name with the given property source object.- Parameters:
- name- the name of the property source to find and replace
- propertySource- the replacement property source
- Throws:
- IllegalArgumentException- if no property source with the given name is present
- See Also:
 
- 
sizepublic int size()Return the number ofPropertySourceobjects contained.
- 
toString
- 
assertLegalRelativeAdditionprotected void assertLegalRelativeAddition(String relativePropertySourceName, PropertySource<?> propertySource) Ensure that the given property source is not being added relative to itself.
- 
removeIfPresentRemove the given property source if it is present.
 
-