Package org.springframework.core.env
Class MapPropertySource
java.lang.Object
org.springframework.core.env.PropertySource<T>
org.springframework.core.env.EnumerablePropertySource<Map<String,Object>>
org.springframework.core.env.MapPropertySource
- Direct Known Subclasses:
PropertiesPropertySource
,SystemEnvironmentPropertySource
PropertySource
that reads keys and values from a Map
object.
The underlying map should not contain any null
values in order to
comply with getProperty(java.lang.String)
and containsProperty(java.lang.String)
semantics.- Since:
- 3.1
- Author:
- Chris Beams, Juergen Hoeller
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.core.env.PropertySource
PropertySource.StubPropertySource
-
Field Summary
Fields inherited from class org.springframework.core.env.PropertySource
logger, name, source
-
Constructor Summary
ConstructorDescriptionMapPropertySource
(String name, Map<String, Object> source) Create a newMapPropertySource
with the given name andMap
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsProperty
(String name) Return whether thisPropertySource
contains a property with the given name.getProperty
(String name) Return the value associated with the given name, ornull
if not found.String[]
Return the names of all properties contained by the source object (nevernull
).
-
Constructor Details
-
MapPropertySource
Create a newMapPropertySource
with the given name andMap
.- Parameters:
name
- the associated namesource
- the Map source (withoutnull
values in order to get consistentgetProperty(java.lang.String)
andcontainsProperty(java.lang.String)
behavior)
-
-
Method Details
-
getProperty
Description copied from class:PropertySource
Return the value associated with the given name, ornull
if not found.- Specified by:
getProperty
in classPropertySource<Map<String,
Object>> - Parameters:
name
- the property to find- See Also:
-
containsProperty
Description copied from class:EnumerablePropertySource
Return whether thisPropertySource
contains a property with the given name.This implementation checks for the presence of the given name within the
EnumerablePropertySource.getPropertyNames()
array.- Overrides:
containsProperty
in classEnumerablePropertySource<Map<String,
Object>> - Parameters:
name
- the name of the property to find
-
getPropertyNames
Description copied from class:EnumerablePropertySource
Return the names of all properties contained by the source object (nevernull
).- Specified by:
getPropertyNames
in classEnumerablePropertySource<Map<String,
Object>>
-