本文整理汇总了Java中com.typesafe.config.Config.entrySet方法的典型用法代码示例。如果您正苦于以下问题:Java Config.entrySet方法的具体用法?Java Config.entrySet怎么用?Java Config.entrySet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.typesafe.config.Config
的用法示例。
在下文中一共展示了Config.entrySet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applySystemProperties
import com.typesafe.config.Config; //导入方法依赖的package包/类
private static Config applySystemProperties(Config config, Config reference){
for (Entry<String, ConfigValue> entry : reference.entrySet()) {
String property = System.getProperty(entry.getKey());
if (property != null && !property.isEmpty()) {
// hack to deal with array of strings
if (property.startsWith("[") && property.endsWith("]")) {
property = property.substring(1, property.length()-1);
if (property.trim().isEmpty()) {
continue;
}
String[] strings = property.split(",");
if (strings != null && strings.length > 0) {
List<String> listStrings = new ArrayList<>();
for (String str : strings) {
listStrings.add(str.trim());
}
config = config.withValue(entry.getKey(), ConfigValueFactory.fromAnyRef(listStrings));
}
} else {
config = config.withValue(entry.getKey(), ConfigValueFactory.fromAnyRef(property));
}
logger.info("Applying provided system property to config: -D{}={}", entry.getKey(), property);
}
}
return config;
}
示例2: InputConfiguration
import com.typesafe.config.Config; //导入方法依赖的package包/类
public InputConfiguration(String id, Config config) {
this.id = id;
if (config.hasPath("outputs")) {
this.outputs = Sets.newHashSet(Splitter.on(",").omitEmptyStrings().trimResults().split(config.getString("outputs")));
}
if (config.hasPath("message-fields")) {
final Config messageFieldsConfig = config.getConfig("message-fields");
for (Map.Entry<String, ConfigValue> entry : messageFieldsConfig.entrySet()) {
final String key = entry.getKey();
final ConfigValue value = entry.getValue();
switch (value.valueType()) {
case NUMBER:
this.messageFields.put(key, messageFieldsConfig.getNumber(key));
break;
case BOOLEAN:
this.messageFields.put(key, messageFieldsConfig.getBoolean(key));
break;
case STRING:
this.messageFields.put(key, messageFieldsConfig.getString(key));
break;
default:
log.warn("{}[{}] Message field value of type \"{}\" is not supported for key \"{}\" (value: {})",
getClass().getSimpleName(), getId(), value.valueType(), key, value.toString());
break;
}
}
}
}
示例3: check
import com.typesafe.config.Config; //导入方法依赖的package包/类
private void check(){
final Config inner = getInnerConfig();
final Config ref = reference.resolve();
// make sure types are right
inner.checkValid(ref);
// make sure we don't have any extra paths. these are typically typos.
List<String> invalidPaths = new ArrayList<>();
for(Entry<String, ConfigValue> entry : inner.entrySet()){
if(!ref.hasPath(entry.getKey())){
invalidPaths.add(entry.getKey());
}
}
if(!invalidPaths.isEmpty()){
StringBuilder sb = new StringBuilder();
sb.append("Failure reading configuration file. The following properties were invalid:\n");
for(String s : invalidPaths){
sb.append("\t");
sb.append(s);
sb.append("\n");
}
throw new RuntimeException(sb.toString());
}
}