public class CompositePropertySource extends PropertySource<Object>
PropertySource
implementation that iterates over a set of
PropertySource
instances. Necessary in cases where multiple property sources
share the same name, e.g. when multiple values are supplied to @PropertySource
.PropertySource.StubPropertySource
logger, name, source
Constructor and Description |
---|
CompositePropertySource(String name)
Create a new
CompositePropertySource . |
Modifier and Type | Method and Description |
---|---|
void |
addFirstPropertySource(PropertySource<?> propertySource)
Add the given
PropertySource to the start of the chain. |
void |
addPropertySource(PropertySource<?> propertySource)
Add the given
PropertySource to the end of the chain. |
Object |
getProperty(String name)
Return the value associated with the given name,
or
null if not found. |
Collection<PropertySource<?>> |
getPropertySources()
Return all property sources that this composite source holds.
|
String |
toString()
Produce concise output (type and name) if the current log level does not include
debug.
|
containsProperty, equals, getName, getSource, hashCode, named
public CompositePropertySource(String name)
CompositePropertySource
.name
- the name of the property sourcepublic Object getProperty(String name)
PropertySource
null
if not found.getProperty
in class PropertySource<Object>
name
- the property to findPropertyResolver.getRequiredProperty(String)
public void addPropertySource(PropertySource<?> propertySource)
PropertySource
to the end of the chain.propertySource
- the PropertySource to addpublic void addFirstPropertySource(PropertySource<?> propertySource)
PropertySource
to the start of the chain.propertySource
- the PropertySource to addpublic Collection<PropertySource<?>> getPropertySources()
public String toString()
PropertySource
This variable verbosity is useful as a property source such as system properties or environment variables may contain an arbitrary number of property pairs, potentially leading to difficult to read exception and log messages.
toString
in class PropertySource<Object>
Log.isDebugEnabled()