本文整理了Java中com.typesafe.config.Config.getObjectList()
方法的一些代码示例,展示了Config.getObjectList()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.getObjectList()
方法的具体详情如下:
包路径:com.typesafe.config.Config
类名称:Config
方法名:getObjectList
暂无
代码示例来源:origin: kairosdb/kairosdb
@Override
public List<?> extractListValue(Config config, String path) {
return config.getObjectList(path);
}
},
代码示例来源:origin: apache/drill
@Override
public List<? extends ConfigObject> getObjectList(String path) {
return c.getObjectList(path);
}
代码示例来源:origin: ethereum/ethereumj
@ValidateMe
public NodeFilter peerTrusted() {
List<? extends ConfigObject> list = config.getObjectList("peer.trusted");
NodeFilter ret = new NodeFilter();
for (ConfigObject configObject : list) {
byte[] nodeId = null;
String ipMask = null;
if (configObject.get("nodeId") != null) {
nodeId = Hex.decode(configObject.toConfig().getString("nodeId").trim());
}
if (configObject.get("ip") != null) {
ipMask = configObject.toConfig().getString("ip").trim();
}
ret.add(nodeId, ipMask);
}
return ret;
}
代码示例来源:origin: ethereum/ethereumj
List<? extends ConfigObject> list = config.getObjectList("peer.active");
for (ConfigObject configObject : list) {
Node n;
代码示例来源:origin: ethereum/ethereumj
@Test
public void fallbackTest() {
System.setProperty("blocks.loader", "bla-bla");
Config config = ConfigFactory.load("ethereumj.conf");
// Ignore this assertion since the SystemProperties are loaded by the static initializer
// so if the ConfigFactory was used prior to this test the setProperty() has no effect
// Assert.assertEquals("bla-bla", config.getString("blocks.loader"));
String string = config.getString("keyvalue.datasource");
Assert.assertNotNull(string);
Config overrides = ConfigFactory.parseString("blocks.loader=another, peer.active=[{url=sdfsfd}]");
Config merged = overrides.withFallback(config);
Assert.assertEquals("another", merged.getString("blocks.loader"));
Assert.assertTrue(merged.getObjectList("peer.active").size() == 1);
Assert.assertNotNull(merged.getString("keyvalue.datasource"));
Config emptyConf = ConfigFactory.parseFile(new File("nosuchfile.conf"), ConfigParseOptions.defaults());
Assert.assertFalse(emptyConf.hasPath("blocks.loader"));
}
代码示例来源:origin: mpusher/mpush
private static Object getListValue(Class<?> beanClass, Type parameterType, Class<?> parameterClass, Config config, String configPropName) {
Type elementType = ((ParameterizedType) parameterType).getActualTypeArguments()[0];
if (elementType == Boolean.class) {
return config.getBooleanList(configPropName);
} else if (elementType == Integer.class) {
return config.getIntList(configPropName);
} else if (elementType == Double.class) {
return config.getDoubleList(configPropName);
} else if (elementType == Long.class) {
return config.getLongList(configPropName);
} else if (elementType == String.class) {
return config.getStringList(configPropName);
} else if (elementType == Duration.class) {
return config.getDurationList(configPropName);
} else if (elementType == ConfigMemorySize.class) {
return config.getMemorySizeList(configPropName);
} else if (elementType == Object.class) {
return config.getAnyRefList(configPropName);
} else if (elementType == Config.class) {
return config.getConfigList(configPropName);
} else if (elementType == ConfigObject.class) {
return config.getObjectList(configPropName);
} else if (elementType == ConfigValue.class) {
return config.getList(configPropName);
} else {
throw new ConfigException.BadBean("Bean property '" + configPropName + "' of class " + beanClass.getName() + " has unsupported list element type " + elementType);
}
}
代码示例来源:origin: ethereum/ethereumj
@Test
public void simpleTest() {
Config config = ConfigFactory.parseResources("ethereumj.conf");
System.out.println(config.root().render(ConfigRenderOptions.defaults().setComments(false)));
for (Map.Entry<String, ConfigValue> entry : config.entrySet()) {
// System.out.println("Name: " + entry.getKey());
// System.out.println(entry);
}
System.out.println("peer.listen.port: " + config.getInt("peer.listen.port"));
System.out.println("peer.discovery.ip.list: " + config.getAnyRefList("peer.discovery.ip.list"));
System.out.println("peer.discovery.ip.list: " + config.getAnyRefList("peer.active"));
List<? extends ConfigObject> list = config.getObjectList("peer.active");
for (ConfigObject configObject : list) {
if (configObject.get("url") != null) {
System.out.println("URL: " + configObject.get("url"));
}
if (configObject.get("ip") != null) {
System.out.println("IP: " + configObject);
}
}
System.out.println("blocks.loader = " + config.hasPath("blocks.loader"));
System.out.println("blocks.loader = " + config.getAnyRef("blocks.loader"));
}
代码示例来源:origin: dremio/dremio-oss
@Override
public List<? extends ConfigObject> getObjectList(String path) {
return config.getObjectList(path);
}
代码示例来源:origin: racc/typesafeconfig-guice
@Override
public List<?> extractListValue(Config config, String path) {
return config.getObjectList(path);
}
},
代码示例来源:origin: org.apache.drill/drill-common
@Override
public List<? extends ConfigObject> getObjectList(String path) {
return c.getObjectList(path);
}
代码示例来源:origin: xjdr/xio
private static ImmutableMap<String, List<Double>> createClientRateLimitOverride(Config config) {
ImmutableMap.Builder<String, List<Double>> builder = ImmutableMap.builder();
config
.getObjectList("reqPerSecondOverride")
.forEach(
each ->
each.forEach(
(key, value) -> {
builder.put(
key,
Arrays.stream(value.unwrapped().toString().split(":"))
.map(Double::parseDouble)
.collect(Collectors.toList()));
}));
return builder.build();
}
}
代码示例来源:origin: cloudera-labs/envelope
@Override
public ValidationResult validate(Config config) {
try {
parseSchema(config.getObjectList(FIELDS_CONFIG));
}
catch (Exception e) {
return new ValidationResult(this, Validity.INVALID, "Schema configuration is invalid");
}
return new ValidationResult(this, Validity.VALID, "Schema configuration is valid");
}
代码示例来源:origin: yahoo/gondola
private void loadAttributes(com.typesafe.config.Config cfg, Map<String, Map<String, String>> attributesMap,
String configSet, String keyName) {
// Get host attribute map
for (ConfigObject h : cfg.getObjectList(configSet)) {
String hostId = String.valueOf(h.get(keyName).unwrapped());
Map<String, String> hostAttribute = new HashMap<>();
attributesMap.put(hostId, hostAttribute);
for (String key : h.keySet()) {
hostAttribute.put(key, String.valueOf(h.get(key).unwrapped()));
}
}
}
代码示例来源:origin: cloudera-labs/envelope
@Override
public void configure(String name, Config config) {
this.name = name;
List<? extends ConfigObject> fields = config.getObjectList(FIELDS_CONFIG);
requiredSchema = parseSchema(fields);
exactMatch = ConfigUtils.getOrElse(config, EXACT_MATCH_CONFIG, DEFAULT_EXACT_MATCH);
}
代码示例来源:origin: dawnbreaks/NettyRPC
public <T> ArrayList<InetSocketAddress> loadServerListFromConf(Class<T> clazz){
ArrayList<InetSocketAddress> serverList = new ArrayList<InetSocketAddress>();
List<? extends ConfigObject> objConfList = getConfig().getObjectList("client.objects");
for(ConfigObject conf : objConfList){
Object name = conf.get("name").unwrapped();
if(name.equals(clazz.getName())){
String[] servers = ((String)conf.get("servers").unwrapped()).split(" ");
for(int i=0;i<servers.length;i++){
String[] ipAndPort = servers[i].split(":");
serverList.add(new InetSocketAddress(ipAndPort[0],Integer.parseInt(ipAndPort[1])));
}
}
}
if(serverList.isEmpty()){
throw new RuntimeException("server list is empty, can not find any corresponding client.objects in the conf file.");
}
return serverList;
}
代码示例来源:origin: org.opendaylight.controller/sal-distributed-datastore
private static Map<String, ModuleConfig.Builder> readModuleShardsConfig(final Config moduleShardsConfig) {
List<? extends ConfigObject> moduleShardsConfigObjectList =
moduleShardsConfig.getObjectList("module-shards");
Map<String, ModuleConfig.Builder> moduleConfigMap = new HashMap<>();
for(ConfigObject moduleShardConfigObject : moduleShardsConfigObjectList){
String moduleName = moduleShardConfigObject.get("name").unwrapped().toString();
ModuleConfig.Builder builder = ModuleConfig.builder(moduleName);
List<? extends ConfigObject> shardsConfigObjectList =
moduleShardConfigObject.toConfig().getObjectList("shards");
for(ConfigObject shard : shardsConfigObjectList){
String shardName = shard.get("name").unwrapped().toString();
List<MemberName> replicas = shard.toConfig().getStringList("replicas").stream()
.map(MemberName::forName).collect(Collectors.toList());
builder.shardConfig(shardName, replicas);
}
moduleConfigMap.put(moduleName, builder);
}
return moduleConfigMap;
}
代码示例来源:origin: red6/pdfcompare
private void readFromConfig(final Config load) {
final List<? extends ConfigObject> exclusions = load.getObjectList("exclusions");
exclusions.stream().map(co -> {
final Config c = co.toConfig();
if (!c.hasPath("x1") && !c.hasPath("y1") && !c.hasPath("x2") && !c.hasPath("y2")) {
return new PageArea(c.getInt("page"));
}
if (c.hasPath("page")) {
return new PageArea(c.getInt("page"), toPix(c, "x1"), toPix(c, "y1"), toPix(c, "x2"), toPix(c,"y2"));
}
return new PageArea(toPix(c, "x1"), toPix(c, "y1"), toPix(c, "x2"), toPix(c,"y2"));
}).forEach(e -> add(e));
}
代码示例来源:origin: tronprotocol/wallet-cli
public static String selectFullNode() {
Map<String, String> witnessMap = new HashMap<>();
Config config = Configuration.getByPath("config.conf");
List list = config.getObjectList("witnesses.witnessList");
for (int i = 0; i < list.size(); i++) {
ConfigObject obj = (ConfigObject) list.get(i);
String ip = obj.get("ip").unwrapped().toString();
String url = obj.get("url").unwrapped().toString();
witnessMap.put(url, ip);
}
Optional<WitnessList> result = rpcCli.listWitnesses();
long minMissedNum = 100000000L;
String minMissedWitness = "";
if (result.isPresent()) {
List<Witness> witnessList = result.get().getWitnessesList();
for (Witness witness : witnessList) {
String url = witness.getUrl();
long missedBlocks = witness.getTotalMissed();
if (missedBlocks < minMissedNum) {
minMissedNum = missedBlocks;
minMissedWitness = url;
}
}
}
if (witnessMap.containsKey(minMissedWitness)) {
return witnessMap.get(minMissedWitness);
} else {
return "";
}
}
代码示例来源:origin: org.opendaylight.controller/sal-distributed-datastore
private static void readModulesConfig(final Config modulesConfig, Map<String, ModuleConfig.Builder> moduleConfigMap,
Configuration configuration) {
List<? extends ConfigObject> modulesConfigObjectList = modulesConfig.getObjectList("modules");
for(ConfigObject o : modulesConfigObjectList){
ConfigObjectWrapper w = new ConfigObjectWrapper(o);
String moduleName = w.stringValue("name");
ModuleConfig.Builder builder = moduleConfigMap.get(moduleName);
if(builder == null) {
builder = ModuleConfig.builder(moduleName);
moduleConfigMap.put(moduleName, builder);
}
builder.nameSpace(w.stringValue("namespace"));
builder.shardStrategy(ShardStrategyFactory.newShardStrategyInstance(moduleName,
w.stringValue("shard-strategy"), configuration));
}
}
代码示例来源:origin: com.github.mpusher/mpush-tools
private static Object getListValue(Class<?> beanClass, Type parameterType, Class<?> parameterClass, Config config, String configPropName) {
Type elementType = ((ParameterizedType) parameterType).getActualTypeArguments()[0];
if (elementType == Boolean.class) {
return config.getBooleanList(configPropName);
} else if (elementType == Integer.class) {
return config.getIntList(configPropName);
} else if (elementType == Double.class) {
return config.getDoubleList(configPropName);
} else if (elementType == Long.class) {
return config.getLongList(configPropName);
} else if (elementType == String.class) {
return config.getStringList(configPropName);
} else if (elementType == Duration.class) {
return config.getDurationList(configPropName);
} else if (elementType == ConfigMemorySize.class) {
return config.getMemorySizeList(configPropName);
} else if (elementType == Object.class) {
return config.getAnyRefList(configPropName);
} else if (elementType == Config.class) {
return config.getConfigList(configPropName);
} else if (elementType == ConfigObject.class) {
return config.getObjectList(configPropName);
} else if (elementType == ConfigValue.class) {
return config.getList(configPropName);
} else {
throw new ConfigException.BadBean("Bean property '" + configPropName + "' of class " + beanClass.getName() + " has unsupported list element type " + elementType);
}
}
内容来源于网络,如有侵权,请联系作者删除!