Package org.springframework.core.env
Class EnumerablePropertySource<T>
- java.lang.Object
- org.springframework.core.env.PropertySource<T>
- org.springframework.core.env.EnumerablePropertySource<T>
- Direct Known Subclasses:
CommandLinePropertySource,CompositePropertySource,MapPropertySource,PortletConfigPropertySource,PortletContextPropertySource,ServletConfigPropertySource,ServletContextPropertySource
public abstract class EnumerablePropertySource<T> extends PropertySource<T>
APropertySourceimplementation capable of interrogating its underlying source object to enumerate all possible property name/value pairs. Exposes thegetPropertyNames()method to allow callers to introspect available properties without having to access the underlying source object. This also facilitates a more efficient implementation ofcontainsProperty(String), in that it can callgetPropertyNames()and iterate through the returned array rather than attempting a call toPropertySource.getProperty(String)which may be more expensive. Implementations may consider caching the result ofgetPropertyNames()to fully exploit this performance opportunity.Most framework-provided
PropertySourceimplementations are enumerable; a counter-example would beJndiPropertySourcewhere, 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 (viaPropertySource.getProperty(String)) in order to evaluate whether it is present or not.- Since:
- 3.1
- Author:
- Chris Beams, Juergen Hoeller
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
Constructors Modifier Constructor Description protectedEnumerablePropertySource(String name)EnumerablePropertySource(String name, T source)
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancontainsProperty(String name)Return whether thisPropertySourcecontains a property with the given name.abstract String[]getPropertyNames()Return the names of all properties contained by the source object (nevernull).Methods inherited from class org.springframework.core.env.PropertySource
equals, getName, getProperty, getSource, hashCode, named, toString
Constructor Detail
EnumerablePropertySource
public EnumerablePropertySource(String name, T source)
EnumerablePropertySource
protected EnumerablePropertySource(String name)
Method Detail
containsProperty
public boolean containsProperty(String name)
Return whether thisPropertySourcecontains a property with the given name.This implementation checks for the presence of the given name within the
getPropertyNames()array.- Overrides:
containsPropertyin classPropertySource<T>- Parameters:
name- the name of the property to find
getPropertyNames
public abstract String[] getPropertyNames()
Return the names of all properties contained by the source object (nevernull).