org.yelong.support.yaml.YamlMapToProperties Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yelong-support Show documentation
Show all versions of yelong-support Show documentation
对各种开源框架的包装、支持、拓展。这里也包含的yelong-core与orm框架的整合。
默认对所有依赖为 scope 为 provided 。您需要针对自己的需要进行再次依赖
/**
*
*/
package org.yelong.support.yaml;
import java.util.Map;
import java.util.Properties;
import org.yelong.core.annotation.Nullable;
/**
*
* yaml配置map装换为properties
*
* @author PengFei
*/
public class YamlMapToProperties {
public YamlMapToProperties() {
}
public Properties as(Map map) {
return as(map, new Properties());
}
public Properties as(Map map, Properties properties) {
to(null, map, properties);
return properties;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
private void to(@Nullable String prefix, Map map, Properties properties) {
map.forEach((k, v) -> {
String cliedPrefix = prefix == null ? k : prefix + "." + k;
if (v instanceof Map) {
to(cliedPrefix, (Map) v, properties);
} else {
properties.setProperty(cliedPrefix, v.toString());
}
});
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy