Top Description Fields Constructors Methods
org.springframework.core.env

public abstract Class EnumerablePropertySource<T>

extends PropertySource<T>
Class Inheritance
Known Direct Subclasses
org.springframework.core.env.MapPropertySource, org.springframework.core.env.CommandLinePropertySource, org.springframework.core.env.CompositePropertySource
Type Parameters
<T>
the source type
Imports
org.springframework.util.ObjectUtils

A PropertySource implementation capable of interrogating its underlying source object to enumerate all possible property name/value pairs. Exposes the getPropertyNames() method to allow callers to introspect available properties without having to access the underlying source object. This also facilitates a more efficient implementation of containsProperty(String), in that it can call getPropertyNames() and iterate through the returned array rather than attempting a call to getProperty(String) which may be more expensive. Implementations may consider caching the result of getPropertyNames() to fully exploit this performance opportunity.

Most framework-provided PropertySource implementations are enumerable; a counter-example would be JndiPropertySource where, due to the nature of JNDI it is not possible to determine all possible property names at any given time; rather it is only possible to try to access a property (via getProperty(String)) in order to evaluate whether it is present or not.

Authors
Chris Beams, Juergen Hoeller
Since
3.1

Field Summary

Inherited from org.springframework.core.env.PropertySource:
loggernamesource

Constructor Summary

AccessConstructor and Description
public
EnumerablePropertySource(String
the associated name
name
,
T
the source object
source
)

Create a new EnumerablePropertySource with the given name and source object.

protected
EnumerablePropertySource(String
the associated name
name
)

Create a new EnumerablePropertySource with the given name and with a new Object instance as the underlying source.

Method Summary

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

Overrides org.springframework.core.env.PropertySource.containsProperty.

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

public abstract String[]
getPropertyNames()

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

Inherited from org.springframework.core.env.PropertySource:
equalsgetNamegetPropertygetSourcehashCodenamedtoString

Constructor Detail

EnumerablePropertySourceback to summary
public EnumerablePropertySource(String name, T source)

Create a new EnumerablePropertySource with the given name and source object.

Parameters
name:String

the associated name

source:T

the source object

EnumerablePropertySourceback to summary
protected EnumerablePropertySource(String name)

Create a new EnumerablePropertySource with the given name and with a new Object instance as the underlying source.

Parameters
name:String

the associated name

Method Detail

containsPropertyback to summary
public boolean containsProperty(String name)

Overrides org.springframework.core.env.PropertySource.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
getPropertyNamesback to summary
public abstract String[] getPropertyNames()

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