public class MutablePropertySources extends java.lang.Object implements PropertySources
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(org.springframework.core.env.PropertySource<?>)
and addLast(org.springframework.core.env.PropertySource<?>)
, this is with regard to the order in which property sources
will be searched when resolving a given property with a PropertyResolver
.
PropertySourcesPropertyResolver
Modifier and Type | Field and Description |
---|---|
private Log |
logger |
private java.util.List<PropertySource<?>> |
propertySourceList |
Constructor and Description |
---|
MutablePropertySources()
Create a new
MutablePropertySources object. |
MutablePropertySources(Log logger)
Create a new
MutablePropertySources object and inherit the given logger,
usually from an enclosing Environment . |
MutablePropertySources(PropertySources propertySources)
Create a new
MutablePropertySources from the given propertySources
object, preserving the original order of contained PropertySource objects. |
Modifier and Type | Method and Description |
---|---|
void |
addAfter(java.lang.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.
|
void |
addBefore(java.lang.String relativePropertySourceName,
PropertySource<?> propertySource)
Add the given property source object with precedence immediately higher
than the named relative property source.
|
void |
addFirst(PropertySource<?> propertySource)
Add the given property source object with highest precedence.
|
void |
addLast(PropertySource<?> propertySource)
Add the given property source object with lowest precedence.
|
protected void |
assertLegalRelativeAddition(java.lang.String relativePropertySourceName,
PropertySource<?> propertySource)
Ensure that the given property source is not being added relative to itself.
|
private int |
assertPresentAndGetIndex(java.lang.String name)
Assert that the named property source is present and return its index.
|
boolean |
contains(java.lang.String name)
Return whether a property source with the given name is contained.
|
PropertySource<?> |
get(java.lang.String name)
Return the property source with the given name,
null if not found. |
java.util.Iterator<PropertySource<?>> |
iterator() |
int |
precedenceOf(PropertySource<?> propertySource)
Return the precedence of the given property source,
-1 if not found. |
PropertySource<?> |
remove(java.lang.String 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.
|
void |
replace(java.lang.String name,
PropertySource<?> propertySource)
Replace the property source with the given name with the given property source object.
|
int |
size()
Return the number of
PropertySource objects contained. |
java.lang.String |
toString() |
private final Log logger
private final java.util.List<PropertySource<?>> propertySourceList
public MutablePropertySources()
MutablePropertySources
object.public MutablePropertySources(PropertySources propertySources)
MutablePropertySources
from the given propertySources
object, preserving the original order of contained PropertySource
objects.MutablePropertySources(Log logger)
MutablePropertySources
object and inherit the given logger,
usually from an enclosing Environment
.public boolean contains(java.lang.String name)
PropertySources
contains
in interface PropertySources
name
- the name of the property source to findpublic PropertySource<?> get(java.lang.String name)
PropertySources
null
if not found.get
in interface PropertySources
name
- the name of the property source to findpublic java.util.Iterator<PropertySource<?>> iterator()
iterator
in interface java.lang.Iterable<PropertySource<?>>
public void addFirst(PropertySource<?> propertySource)
public void addLast(PropertySource<?> propertySource)
public void addBefore(java.lang.String relativePropertySourceName, PropertySource<?> propertySource)
public void addAfter(java.lang.String relativePropertySourceName, PropertySource<?> propertySource)
public int precedenceOf(PropertySource<?> propertySource)
-1
if not found.public PropertySource<?> remove(java.lang.String name)
null
if not found.name
- the name of the property source to find and removepublic void replace(java.lang.String name, PropertySource<?> propertySource)
name
- the name of the property source to find and replacepropertySource
- the replacement property sourcejava.lang.IllegalArgumentException
- if no property source with the given name is presentcontains(java.lang.String)
public int size()
PropertySource
objects contained.public java.lang.String toString()
toString
in class java.lang.Object
protected void assertLegalRelativeAddition(java.lang.String relativePropertySourceName, PropertySource<?> propertySource)
protected void removeIfPresent(PropertySource<?> propertySource)
private void addAtIndex(int index, PropertySource<?> propertySource)
private int assertPresentAndGetIndex(java.lang.String name)
name
- the name of the property source
to findjava.lang.IllegalArgumentException
- if the named property source is not present