You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
963 B
963 B
Spring MapPropertySource
-
Author: HuiFer
-
源码阅读仓库: SourceHot-spring
-
类全路径:
org.springframework.core.env.MapPropertySource
-
内部数据结构是一个
Map<String,Object>
这是一个对 map 的操作. -
整体代码如下.
public class MapPropertySource extends EnumerablePropertySource<Map<String, Object>> {
public MapPropertySource(String name, Map<String, Object> source) {
super(name, source);
}
@Override
@Nullable
public Object getProperty(String name) {
// 从map中获取 name 对应的value
return this.source.get(name);
}
@Override
public boolean containsProperty(String name) {
// 判断是否存在 name 属性
return this.source.containsKey(name);
}
@Override
public String[] getPropertyNames() {
// 互殴去 map 的所有key
return StringUtils.toStringArray(this.source.keySet());
}
}