-
Author: HuiFer
-
源码阅读仓库: SourceHot-spring
-
全路径:
org.springframework.core.env.EnumerablePropertySource
-
在这个类中定义了一个抽象方法
getPropertyNames
用来获取所有的 property 的名称
public abstract String[] getPropertyNames();
- 整体代码如下
public abstract class EnumerablePropertySource<T> extends PropertySource<T> {
public EnumerablePropertySource(String name, T source) {
super(name, source);
}
protected EnumerablePropertySource(String name) {
super(name);
}
/**
* Return whether this {@code PropertySource} contains a property with the given name.
* <p>This implementation checks for the presence of the given name within the
* {@link #getPropertyNames()} array.
*
* 在属性列表中是否存在 properties
* @param name the name of the property to find
*/
@Override
public boolean containsProperty(String name) {
return ObjectUtils.containsElement(getPropertyNames(), name);
}
/**
* Return the names of all properties contained by the
* 获取所有的 properties 名称
* {@linkplain #getSource() source} object (never {@code null}).
*/
public abstract String[] getPropertyNames();
}