Top Description Constructors Methods
org.springframework.core.env

public Class MapPropertySource

extends EnumerablePropertySource<Map<String, Object>>
Class Inheritance
Known Direct Subclasses
org.springframework.core.env.PropertiesPropertySource, org.springframework.core.env.SystemEnvironmentPropertySource
Imports
java.util.Map, org.springframework.lang.Nullable, org.springframework.util.StringUtils

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 and containsProperty semantics.
Authors
Chris Beams, Juergen Hoeller
Since
3.1
See Also
PropertiesPropertySource

Constructor Summary

AccessConstructor and Description
public
MapPropertySource(String
the associated name
name
,
Map<String, Object>
the Map source (without null values in order to get consistent getProperty and containsProperty behavior)
source
)

Create a new MapPropertySource with the given name and Map.

Method Summary

Modifier and TypeMethod and Description
public boolean
containsProperty(String
the name of the property to find
name
)

Overrides org.springframework.core.env.EnumerablePropertySource.containsProperty.

Return whether this PropertySource contains a property with the given name.

public Object
getProperty(String
the property to find
name
)

Implements abstract org.springframework.core.env.PropertySource.getProperty.

Return the value associated with the given name, or null if not found.

public String[]
getPropertyNames()

Implements abstract org.springframework.core.env.EnumerablePropertySource.getPropertyNames.

Return the names of all properties contained by the source object (never null).

Constructor Detail

MapPropertySourceback to summary
public MapPropertySource(String name, Map<String, Object> source)

Create a new MapPropertySource with the given name and Map.

Parameters
name:String

the associated name

source:Map<String, Object>

the Map source (without null values in order to get consistent getProperty and containsProperty behavior)

Method Detail

containsPropertyback to summary
public boolean containsProperty(String name)

Overrides org.springframework.core.env.EnumerablePropertySource.containsProperty.

Doc from org.springframework.core.env.EnumerablePropertySource.containsProperty.

Return whether this PropertySource contains a property with the given name.

This implementation checks for the presence of the given name within the getPropertyNames() array.

Parameters
name:String

the name of the property to find

Annotations
@Override
getPropertyback to summary
public Object getProperty(String name)

Implements abstract org.springframework.core.env.PropertySource.getProperty.

Doc from org.springframework.core.env.PropertySource.getProperty.

Return the value associated with the given name, or null if not found.

Parameters
name:String

the property to find

Annotations
@Override
@Nullable
getPropertyNamesback to summary
public String[] getPropertyNames()

Implements abstract org.springframework.core.env.EnumerablePropertySource.getPropertyNames.

Doc from org.springframework.core.env.EnumerablePropertySource.getPropertyNames.

Return the names of all properties contained by the source object (never null).

Annotations
@Override