java.lang.Object
org.springframework.core.env.PropertySource <T>
org.springframework.core.env.EnumerablePropertySource < Map < String , Object >>
org.springframework.core.env.MapPropertySource
public class MapPropertySource extends EnumerablePropertySource < Map < String , Object >>
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:
Author:
Chris Beams, Juergen Hoeller
See Also:
  • PropertiesPropertySource
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.springframework.core.env. PropertySource

    PropertySource.StubPropertySource
    Return whether this PropertySource contains a property with the given name.
    Return the value associated with the given name, or null if not found.
    Return the names of all properties contained by the source object (never null ).

    Methods inherited from class org.springframework.core.env. PropertySource

    equals , getName , getSource , hashCode , named , toString

    Methods inherited from class java.lang. Object

    clone , finalize , getClass , notify , notifyAll , wait , wait , wait
    public MapPropertySource ( String name, Map < String , Object > source)
    Create a new MapPropertySource with the given name and Map .
    Parameters:
    name - the associated name
    source - the Map source (without null values in order to get consistent getProperty(java.lang.String) and containsProperty(java.lang.String) behavior)
    @Nullable public Object getProperty ( String name)
    Description copied from class: PropertySource
    Return the value associated with the given name, or null if not found.
    Specified by:
    getProperty in class PropertySource < Map < String , Object >>
    Parameters:
    name - the property to find
    See Also:
  • PropertyResolver.getRequiredProperty(String)
  • containsProperty

    public boolean containsProperty ( String name)
    Description copied from class: EnumerablePropertySource
    Return whether this PropertySource 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 class EnumerablePropertySource < Map < String , Object >>
    Parameters:
    name - the name of the property to find

    getPropertyNames

    public String [] getPropertyNames ()
    Description copied from class: EnumerablePropertySource
    Return the names of all properties contained by the source object (never null ).
    Specified by:
    getPropertyNames in class EnumerablePropertySource < Map < String , Object >>