类 MutablePropertySources
- java.lang.Object
- org.springframework.core.env.MutablePropertySources
- 所有已实现的接口:
Iterable<PropertySource<?>>,PropertySources
public class MutablePropertySources extends Object implements PropertySources
The default implementation of thePropertySourcesinterface. Allows manipulation of contained property sources and provides a constructor for copying an existingPropertySourcesinstance.Where precedence is mentioned in methods such as
addFirst(org.springframework.core.env.PropertySource<?>)andaddLast(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 aPropertyResolver.- 从以下版本开始:
- 3.1
- 作者:
- Chris Beams, Juergen Hoeller
- 另请参阅:
PropertySourcesPropertyResolver
构造器概要
构造器 构造器 说明 MutablePropertySources()Create a newMutablePropertySourcesobject.MutablePropertySources(PropertySources propertySources)Create a newMutablePropertySourcesfrom the given propertySources object, preserving the original order of containedPropertySourceobjects.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidaddAfter(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 highest precedence.voidaddLast(PropertySource<?> propertySource)Add the given property source object with lowest precedence.protected voidassertLegalRelativeAddition(String relativePropertySourceName, PropertySource<?> propertySource)Ensure that the given property source is not being added relative to itself.booleancontains(String name)Return whether a property source with the given name is contained.PropertySource<?>get(String name)Return the property source with the given name,nullif not found.Iterator<PropertySource<?>>iterator()intprecedenceOf(PropertySource<?> propertySource)Return the precedence of the given property source,-1if not found.PropertySource<?>remove(String name)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.Spliterator<PropertySource<?>>spliterator()Stream<PropertySource<?>>stream()Return a sequentialStreamcontaining the property sources.StringtoString()
构造器详细资料
MutablePropertySources
public MutablePropertySources()
Create a newMutablePropertySourcesobject.
MutablePropertySources
public MutablePropertySources(PropertySources propertySources)
Create a newMutablePropertySourcesfrom the given propertySources object, preserving the original order of containedPropertySourceobjects.
方法详细资料
iterator
public Iterator<PropertySource<?>> iterator()
- 指定者:
iterator在接口中Iterable<PropertySource<?>>
spliterator
public Spliterator<PropertySource<?>> spliterator()
- 指定者:
spliterator在接口中Iterable<PropertySource<?>>
stream
public Stream<PropertySource<?>> stream()
从接口复制的说明:PropertySourcesReturn a sequentialStreamcontaining the property sources.- 指定者:
stream在接口中PropertySources
contains
public boolean contains(String name)
从接口复制的说明:PropertySourcesReturn whether a property source with the given name is contained.- 指定者:
contains在接口中PropertySources- 参数:
name- the name of the property source to find
get
@Nullable public PropertySource<?> get(String name)
从接口复制的说明:PropertySourcesReturn the property source with the given name,nullif not found.- 指定者:
get在接口中PropertySources- 参数:
name- the name of the property source to find
addFirst
public void addFirst(PropertySource<?> propertySource)
Add the given property source object with highest precedence.
addLast
public void addLast(PropertySource<?> propertySource)
Add the given property source object with lowest precedence.
addBefore
public void addBefore(String relativePropertySourceName, PropertySource<?> propertySource)
Add the given property source object with precedence immediately higher than the named relative property source.
addAfter
public void addAfter(String relativePropertySourceName, PropertySource<?> propertySource)
Add the given property source object with precedence immediately lower than the named relative property source.
precedenceOf
public int precedenceOf(PropertySource<?> propertySource)
Return the precedence of the given property source,-1if not found.
remove
@Nullable public PropertySource<?> remove(String name)
Remove and return the property source with the given name,nullif not found.- 参数:
name- the name of the property source to find and remove
replace
public void replace(String name, PropertySource<?> propertySource)
Replace the property source with the given name with the given property source object.- 参数:
name- the name of the property source to find and replacepropertySource- the replacement property source- 抛出:
IllegalArgumentException- if no property source with the given name is present- 另请参阅:
contains(java.lang.String)
size
public int size()
Return the number ofPropertySourceobjects contained.
assertLegalRelativeAddition
protected void assertLegalRelativeAddition(String relativePropertySourceName, PropertySource<?> propertySource)
Ensure that the given property source is not being added relative to itself.
removeIfPresent
protected void removeIfPresent(PropertySource<?> propertySource)
Remove the given property source if it is present.