PropertySource意为属性源,它只有两个变量,且均为final类型。既然是属性源,那么就一定可以从中获取某个属性的值,即含有getProperty方法,它的主要方法如下:
public abstract class PropertySource<T> {
//表示这个属性源的名字
protected final String name;
//表示这个属性源的源
protected final T source;
public PropertySource(String name, T source) {
this.name = name;
this.source = source;
}
public PropertySource(String name) {
this(name, (T) new Object());
}
public String getName() {
return this.name;
}
public T getSource() {
return this.source;
}
public boolean containsProperty(String name) {
return (getProperty(name) != null);
}
@Nullable
public abstract Object getProperty(String name);
}