63 Star 427 Fork 156

huifer/Code-Analysis

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Spring-MapPropertySource.md 967 Bytes
一键复制 编辑 原始数据 按行查看 历史
huifer 提交于 5年前 . :fire:doc: env + PropertyResolver

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());
	}

}

Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/pychfarm_admin/code-analysis.git
git@gitee.com:pychfarm_admin/code-analysis.git
pychfarm_admin
code-analysis
Code-Analysis
v0.0.15

搜索帮助