本文整理汇总了Java中com.typesafe.config.Config.getStringList方法的典型用法代码示例。如果您正苦于以下问题:Java Config.getStringList方法的具体用法?Java Config.getStringList怎么用?Java Config.getStringList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.typesafe.config.Config
的用法示例。
在下文中一共展示了Config.getStringList方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createClient
import com.typesafe.config.Config; //导入方法依赖的package包/类
private TransportClient createClient() {
Config cfg = getTypeCfg();
Settings settings = Settings.builder().put("cluster.name", cfg.getString("elastic.cluster-name")).build();
TransportClient client = new PreBuiltTransportClient(settings);
List<String> servers = cfg.getStringList("elastic.servers");
logger.debug(marker, "Elastic Servers: {}", servers);
for (String addr : servers) {
try {
String[] a = addr.split(":");
String host = a[0];
int port = Integer.parseInt(a[1]);
client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(host), port));
} catch (Exception e) {
logger.error(marker, "Transport client creation failed for '{}'", addr, e);
}
}
return client;
}
示例2: DataParams
import com.typesafe.config.Config; //导入方法依赖的package包/类
public DataParams(Config config, String prefix) {
train = new Train(config, prefix + KEY);
test = new Test(config, prefix + KEY);
delim = new Delim(config, prefix + KEY);
y_sampling = config.getStringList(prefix + KEY + "y_sampling");
assigned = config.getBoolean(prefix + KEY + "assigned");
unassigned_mode = UnassignedMode.getMode(config.getString(prefix + KEY + "unassigned_mode"));
for (String s : y_sampling) {
CheckUtils.check(s.matches("\\[email protected](-?\\d+)(\\.\\d+)?"),
"%sy_sampling:%s must be the format of [email protected] e.g [email protected]#0.1",
prefix + KEY, s);
}
CheckUtils.check(unassigned_mode != UnassignedMode.UNKNOWN,
"unknown %sunassigned_mode:%s, only support:%s",
prefix + KEY, unassigned_mode.toString(), UnassignedMode.allToString());
}
示例3: LossParams
import com.typesafe.config.Config; //导入方法依赖的package包/类
public LossParams(Config config, String prefix) {
loss_function = config.getString(prefix + KEY + "loss_function");
regularization = new Regularization(config, prefix + KEY);
evaluate_metric = config.getStringList(prefix + KEY + "evaluate_metric");
just_evaluate = config.getBoolean(prefix + KEY + "just_evaluate");
for (String metric : evaluate_metric) {
if (!EvaluatorFactory.EvalNameSet.contains(metric)) {
boolean hit = false;
for (String eval : EvaluatorFactory.EvalNameSet) {
if (metric.startsWith(eval)) {
hit = true;
}
}
CheckUtils.check(hit, "%sevaluate_metric:%s, only support:%s",
prefix + KEY, metric, EvaluatorFactory.EvalNameSet);
}
}
}
示例4: getRpcModules
import com.typesafe.config.Config; //导入方法依赖的package包/类
public List<ModuleDescription> getRpcModules() {
if (this.moduleDescriptions != null) {
return this.moduleDescriptions;
}
List<ModuleDescription> modules = new ArrayList<>();
if (!configFromFiles.hasPath("rpc.modules")) {
return modules;
}
List<? extends ConfigObject> list = configFromFiles.getObjectList("rpc.modules");
for (ConfigObject configObject : list) {
Config configElement = configObject.toConfig();
String name = configElement.getString("name");
String version = configElement.getString("version");
boolean enabled = configElement.getBoolean("enabled");
List<String> enabledMethods = null;
List<String> disabledMethods = null;
if (configElement.hasPath("methods.enabled")) {
enabledMethods = configElement.getStringList("methods.enabled");
}
if (configElement.hasPath("methods.disabled")) {
disabledMethods = configElement.getStringList("methods.disabled");
}
modules.add(new ModuleDescription(name, version, enabled, enabledMethods, disabledMethods));
}
this.moduleDescriptions = modules;
return modules;
}
示例5: main
import com.typesafe.config.Config; //导入方法依赖的package包/类
public static void main(String[] args) {
// {{start:resource}}
Config defaultConfig = ConfigFactory.parseResources("defaults.conf");
// {{end:resource}}
// {{start:fallback}}
Config fallbackConfig = ConfigFactory.parseResources("overrides.conf")
.withFallback(defaultConfig)
.resolve();
// {{end:fallback}}
// {{start:text}}
log.info("name: {}", defaultConfig.getString("conf.name"));
log.info("name: {}", fallbackConfig.getString("conf.name"));
log.info("title: {}", defaultConfig.getString("conf.title"));
log.info("title: {}", fallbackConfig.getString("conf.title"));
// {{end:text}}
// {{start:resolved}}
log.info("combined: {}", fallbackConfig.getString("conf.combined"));
// {{end:resolved}}
// {{start:durations}}
log.info("redis.ttl minutes: {}", fallbackConfig.getDuration("redis.ttl", TimeUnit.MINUTES));
log.info("redis.ttl seconds: {}", fallbackConfig.getDuration("redis.ttl", TimeUnit.SECONDS));
// {{end:durations}}
// {{start:memorySize}}
// Any path in the configuration can be treated as a separate Config object.
Config uploadService = fallbackConfig.getConfig("uploadService");
log.info("maxChunkSize bytes: {}", uploadService.getMemorySize("maxChunkSize").toBytes());
log.info("maxFileSize bytes: {}", uploadService.getMemorySize("maxFileSize").toBytes());
// {{end:memorySize}}
// {{start:whitelist}}
List<Integer> whiteList = fallbackConfig.getIntList("conf.nested.whitelistIds");
log.info("whitelist: {}", whiteList);
List<String> whiteListStrings = fallbackConfig.getStringList("conf.nested.whitelistIds");
log.info("whitelist as Strings: {}", whiteListStrings);
// {{end:whitelist}}
// {{start:booleans}}
log.info("yes: {}", fallbackConfig.getBoolean("featureFlags.featureA"));
log.info("true: {}", fallbackConfig.getBoolean("featureFlags.featureB"));
// {{end:booleans}}
}
示例6: getOptionalStringList
import com.typesafe.config.Config; //导入方法依赖的package包/类
/**
* @param config configuration to query for value
* @param key configuration path key
* @return value for given key, or {@code null} if none exists
*/
public static List<String> getOptionalStringList(Config config, String key) {
return config.hasPath(key) ? config.getStringList(key) : null;
}