Class MutablePropertySources
- java.lang.Object
-
- cn.sliew.milky.common.environment.MutablePropertySources
-
- All Implemented Interfaces:
PropertySourceIterable,Iterable<PropertySource<?>>
public class MutablePropertySources extends Object implements PropertySourceIterable
The default implementation of thePropertySourceIterableinterface.
-
-
Constructor Summary
Constructors Constructor Description MutablePropertySources()Create a newMutablePropertySourcesobject.MutablePropertySources(PropertySourceIterable propertySources)Create a newMutablePropertySourcesfrom the given propertySources object, preserving the original order of containedPropertySourceobjects.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.booleancontainsPropertySource(String name)Whether a property source with the given name is contained.Optional<PropertySource<?>>getPropertySource(String name)Find the property source with the given name,Optional.empty()if not found.Iterator<PropertySource<?>>iterator()intprecedenceOf(PropertySource<?> propertySource)Return the precedence of the given property source,-1if not found.Optional<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()StringtoString()
-
-
-
Constructor Detail
-
MutablePropertySources
public MutablePropertySources()
Create a newMutablePropertySourcesobject.
-
MutablePropertySources
public MutablePropertySources(PropertySourceIterable propertySources)
Create a newMutablePropertySourcesfrom the given propertySources object, preserving the original order of containedPropertySourceobjects.
-
-
Method Detail
-
iterator
public Iterator<PropertySource<?>> iterator()
- Specified by:
iteratorin interfaceIterable<PropertySource<?>>
-
spliterator
public Spliterator<PropertySource<?>> spliterator()
- Specified by:
spliteratorin interfaceIterable<PropertySource<?>>
-
stream
public Stream<PropertySource<?>> stream()
- Specified by:
streamin interfacePropertySourceIterable
-
containsPropertySource
public boolean containsPropertySource(String name)
Description copied from interface:PropertySourceIterableWhether a property source with the given name is contained.- Specified by:
containsPropertySourcein interfacePropertySourceIterable- Parameters:
name- thename of the property sourceto find
-
getPropertySource
public Optional<PropertySource<?>> getPropertySource(String name)
Description copied from interface:PropertySourceIterableFind the property source with the given name,Optional.empty()if not found.- Specified by:
getPropertySourcein interfacePropertySourceIterable- Parameters:
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
public Optional<PropertySource<?>> remove(String name)
Remove and return the property source with the given name,nullif not found.- Parameters:
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.- Parameters:
name- the name of the property source to find and replacepropertySource- the replacement property source- Throws:
IllegalArgumentException- if no property source with the given name is present- See Also:
containsPropertySource(String)
-
size
public int size()
Return the number ofPropertySourceobjects contained.
-
removeIfPresent
protected void removeIfPresent(PropertySource<?> propertySource)
Remove the given property source if it is present.
-
assertLegalRelativeAddition
protected void assertLegalRelativeAddition(String relativePropertySourceName, PropertySource<?> propertySource)
Ensure that the given property source is not being added relative to itself.
-
-