类 EnumerablePropertySource<T>
- java.lang.Object
- org.springframework.core.env.PropertySource<T>
- org.springframework.core.env.EnumerablePropertySource<T>
- 直接已知子类:
CommandLinePropertySource
,CompositePropertySource
,MapPropertySource
,PortletConfigPropertySource
,PortletContextPropertySource
,ServletConfigPropertySource
,ServletContextPropertySource
public abstract class EnumerablePropertySource<T> extends PropertySource<T>
APropertySource
implementation 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
PropertySource
implementations are enumerable; a counter-example would beJndiPropertySource
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 (viaPropertySource.getProperty(String)
) in order to evaluate whether it is present or not.- 从以下版本开始:
- 3.1
- 作者:
- Chris Beams, Juergen Hoeller
嵌套类概要
从类继承的嵌套类/接口 org.springframework.core.env.PropertySource
PropertySource.StubPropertySource
字段概要
从类继承的字段 org.springframework.core.env.PropertySource
logger, name, source
构造器概要
构造器 限定符 构造器 说明 protected
EnumerablePropertySource(String name)
EnumerablePropertySource(String name, T source)
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 boolean
containsProperty(String name)
Return whether thisPropertySource
contains a property with the given name.abstract String[]
getPropertyNames()
Return the names of all properties contained by the source object (nevernull
).从类继承的方法 org.springframework.core.env.PropertySource
equals, getName, getProperty, getSource, hashCode, named, toString
构造器详细资料
EnumerablePropertySource
public EnumerablePropertySource(String name, T source)
EnumerablePropertySource
protected EnumerablePropertySource(String name)
方法详细资料
containsProperty
public boolean containsProperty(String name)
Return whether thisPropertySource
contains a property with the given name.This implementation checks for the presence of the given name within the
getPropertyNames()
array.- 覆盖:
containsProperty
在类中PropertySource<T>
- 参数:
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
).