Top Description Fields Constructors Methods
org.springframework.core.env

public Class MutablePropertySources

extends Object
implements PropertySources
Class Inheritance
All Implemented Interfaces
org.springframework.core.env.PropertySources, java.lang.Iterable
Imports
java.util.Iterator, .List, .Spliterator, .Spliterators, java.util.concurrent.CopyOnWriteArrayList, java.util.stream.Stream, org.springframework.lang.Nullable

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 and addLast, this is with regard to the order in which property sources will be searched when resolving a given property with a PropertyResolver.

Authors
Chris Beams, Juergen Hoeller
Since
3.1
See Also
PropertySourcesPropertyResolver

Field Summary

Modifier and TypeField and Description
private final List<PropertySource<?>>

Constructor Summary

AccessConstructor and Description
public
public
MutablePropertySources(PropertySources propertySources)

Create a new MutablePropertySources from the given propertySources object, preserving the original order of contained PropertySource objects.

Method Summary

Modifier and TypeMethod and Description
public void
addAfter(String relativePropertySourceName, PropertySource<?> propertySource)

Add the given property source object with precedence immediately lower than the named relative property source.

private void
addAtIndex(int index, PropertySource<?> propertySource)

Add the given property source at a particular index in the list.

public void
addBefore(String relativePropertySourceName, PropertySource<?> propertySource)

Add the given property source object with precedence immediately higher than the named relative property source.

public void
addFirst(PropertySource<?> propertySource)

Add the given property source object with the highest precedence.

public void
addLast(PropertySource<?> propertySource)

Add the given property source object with the lowest precedence.

protected void
assertLegalRelativeAddition(String relativePropertySourceName, PropertySource<?> propertySource)

Ensure that the given property source is not being added relative to itself.

private int
assertPresentAndGetIndex(String name)

Assert that the named property source is present and return its index.

public boolean
contains(String name)

Implements org.springframework.core.env.PropertySources.contains.

Return whether a property source with the given name is contained.
public PropertySource<?>
get(String name)

Implements org.springframework.core.env.PropertySources.get.

Return the property source with the given name, null if not found.
public Iterator<PropertySource<?>>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.
public int
precedenceOf(PropertySource<?> propertySource)

Return the precedence of the given property source, -1 if not found.

public PropertySource<?>
remove(String
the name of the property source to find and remove
name
)

Remove and return the property source with the given name, null if not found.

protected void
removeIfPresent(PropertySource<?> propertySource)

Remove the given property source if it is present.

public void
replace(String
the name of the property source to find and replace
name
,
PropertySource<?>
the replacement property source
propertySource
)

Replace the property source with the given name with the given property source object.

public int
size()

Return the number of PropertySource objects contained.

public Spliterator<PropertySource<?>>
spliterator()

Overrides default java.lang.Iterable.spliterator.

Creates a Spliterator over the elements described by this Iterable.
public Stream<PropertySource<?>>
stream()

Overrides default org.springframework.core.env.PropertySources.stream.

Return a sequential Stream containing the property sources.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

propertySourceListback to summary
private final List<PropertySource<?>> propertySourceList

Constructor Detail

MutablePropertySourcesback to summary
public MutablePropertySources()

Create a new MutablePropertySources object.

MutablePropertySourcesback to summary
public MutablePropertySources(PropertySources propertySources)

Create a new MutablePropertySources from the given propertySources object, preserving the original order of contained PropertySource objects.

Method Detail

addAfterback to summary
public void addAfter(String relativePropertySourceName, PropertySource<?> propertySource)

Add the given property source object with precedence immediately lower than the named relative property source.

addAtIndexback to summary
private void addAtIndex(int index, PropertySource<?> propertySource)

Add the given property source at a particular index in the list.

addBeforeback to summary
public void addBefore(String relativePropertySourceName, PropertySource<?> propertySource)

Add the given property source object with precedence immediately higher than the named relative property source.

addFirstback to summary
public void addFirst(PropertySource<?> propertySource)

Add the given property source object with the highest precedence.

addLastback to summary
public void addLast(PropertySource<?> propertySource)

Add the given property source object with the lowest precedence.

assertLegalRelativeAdditionback to summary
protected void assertLegalRelativeAddition(String relativePropertySourceName, PropertySource<?> propertySource)

Ensure that the given property source is not being added relative to itself.

assertPresentAndGetIndexback to summary
private int assertPresentAndGetIndex(String name)

Assert that the named property source is present and return its index.

Parameters
name:String

name of the property source to find

Exceptions
IllegalArgumentException:
if the named property source is not present
containsback to summary
public boolean contains(String name)

Implements org.springframework.core.env.PropertySources.contains.

Doc from org.springframework.core.env.PropertySources.contains.

Return whether a property source with the given name is contained.

Parameters
name:String

the name of the property source to find

Annotations
@Override
getback to summary
public PropertySource<?> get(String name)

Implements org.springframework.core.env.PropertySources.get.

Doc from org.springframework.core.env.PropertySources.get.

Return the property source with the given name, null if not found.

Parameters
name:String

the name of the property source to find

Annotations
@Override
@Nullable
iteratorback to summary
public Iterator<PropertySource<?>> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<PropertySource<?>>

an Iterator.

Annotations
@Override
precedenceOfback to summary
public int precedenceOf(PropertySource<?> propertySource)

Return the precedence of the given property source, -1 if not found.

removeback to summary
public PropertySource<?> remove(String name)

Remove and return the property source with the given name, null if not found.

Parameters
name:String

the name of the property source to find and remove

Annotations
@Nullable
removeIfPresentback to summary
protected void removeIfPresent(PropertySource<?> propertySource)

Remove the given property source if it is present.

replaceback to summary
public void replace(String name, PropertySource<?> propertySource)

Replace the property source with the given name with the given property source object.

Parameters
name:String

the name of the property source to find and replace

propertySource:PropertySource<?>

the replacement property source

Exceptions
IllegalArgumentException:
if no property source with the given name is present
See Also
contains
sizeback to summary
public int size()

Return the number of PropertySource objects contained.

spliteratorback to summary
public Spliterator<PropertySource<?>> spliterator()

Overrides default java.lang.Iterable.spliterator.

Doc from java.lang.Iterable.spliterator.

Creates a Spliterator over the elements described by this Iterable.

Returns:Spliterator<PropertySource<?>>

a Spliterator over the elements described by this Iterable.

Annotations
@Override
streamback to summary
public Stream<PropertySource<?>> stream()

Overrides default org.springframework.core.env.PropertySources.stream.

Doc from org.springframework.core.env.PropertySources.stream.

Return a sequential Stream containing the property sources.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override