本文整理了Java中io.helidon.config.Config.asString()
方法的一些代码示例,展示了Config.asString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.asString()
方法的具体详情如下:
包路径:io.helidon.config.Config
类名称:Config
方法名:asString
[英]String typed value.
[中]字符串类型的值。
代码示例来源:origin: oracle/helidon
@Override
protected String invokeParameter(Config config) {
return config.asString().get();
}
}
代码示例来源:origin: oracle/helidon
private String format(String template) {
Matcher m = PATTERN_REFERENCE.matcher(template);
final StringBuffer sb = new StringBuffer();
while (m.find()) {
m.appendReplacement(sb, Matcher.quoteReplacement(root.get(m.group(1)).asString().get()));
}
m.appendTail(sb);
// remove all backslash that encodes ${...}
m = PATTERN_BACKSLASH.matcher(sb.toString());
return m.replaceAll("");
}
}
代码示例来源:origin: oracle/helidon
@Override
public <T> Config.Builder addStringMapper(Class<T> type, Function<String, T> mapper) {
Objects.requireNonNull(type);
Objects.requireNonNull(mapper);
addMapper(type, config -> mapper.apply(config.asString().get()));
return this;
}
代码示例来源:origin: oracle/helidon
@Override
public OptionalInt apply(Config config) throws ConfigMappingException, MissingValueException {
if (config.type() == Config.Type.MISSING) {
return OptionalInt.empty();
}
return OptionalInt.of(Integer.parseInt(config.asString().get()) - 1);
}
代码示例来源:origin: oracle/helidon
/**
* Update builder from configuration.
*
* @param config config located on key of this validator
* @return updated builder instance
*/
public Builder config(Config config) {
config.get("operator").asString().map("OR"::equals).ifPresent(this::useOrOperator);
return this;
}
}
代码示例来源:origin: oracle/helidon
@Override
public Locale apply(Config config) throws ConfigMappingException, MissingValueException {
String language = config.get("language").asString().get();
String country = config.get("country").asString().orElse("");
String variant = config.get("variant").asString().orElse("");
return new Locale("m2:" + language, "m2:" + country, "m2:" + variant);
}
代码示例来源:origin: oracle/helidon
@Override
public Locale apply(Config config) throws ConfigMappingException, MissingValueException {
String language = config.get("language").asString().get();
String country = config.get("country").asString().orElse("");
String variant = config.get("variant").asString().orElse("");
return new Locale(language, country, variant);
}
代码示例来源:origin: oracle/helidon
/**
* Parse configuration into this enum.
*
* @param config Config with wrapped enum value
* @return enum instance
*/
public static Qop create(Config config) {
return fromString(config.asString().get());
}
代码示例来源:origin: oracle/helidon
/**
* Override default configuration.
*
* @param config configuration instance
* @return updated builder instance
* @see MetricsSupport for details about configuration keys
*/
public Builder config(Config config) {
this.config = config;
config.get("helidon.metrics.context").asString().ifPresent(this::context);
return this;
}
代码示例来源:origin: oracle/helidon
private static Optional<String> value(Config node) {
if (node instanceof AbstractConfigImpl) {
return ((AbstractConfigImpl) node).value();
}
return node.asString().asOptional();
}
代码示例来源:origin: oracle/helidon
static Optional<Resource> fromConfigB64Content(Config config, String keyPrefix) {
return config.get(keyPrefix + "-content")
.asString()
.map(Base64.getDecoder()::decode)
.map(content -> Resource.create("config:" + keyPrefix + "-content-b64", content));
}
代码示例来源:origin: oracle/helidon
private static Optional<String> nodeValue(Config node) {
if (node instanceof AbstractConfigImpl) {
return ((AbstractConfigImpl) node).value();
}
return node.asString().asOptional();
}
代码示例来源:origin: oracle/helidon
private void outbound(Config config) {
// jwk is optional, we may be propagating existing token
Resource.create(config, "jwk").ifPresent(this::signJwk);
config.get("jwt-issuer").asString().ifPresent(this::issuer);
}
}
代码示例来源:origin: oracle/helidon
private void outbound(Config config) {
// jwk is optional, we may be propagating existing token
Resource.create(config, "jwk").ifPresent(this::signJwk);
config.get("jwt-issuer").asString().ifPresent(this::issuer);
}
}
代码示例来源:origin: oracle/helidon
static Optional<Resource> fromConfigContent(Config config, String keyPrefix) {
return config.get(keyPrefix + "-content-plain")
.asString()
.map(content -> Resource.create("config:" + keyPrefix + "-content", content));
}
代码示例来源:origin: oracle/helidon
static ConfigUser create(Config config) {
ConfigUser cu = new ConfigUser();
cu.login = config.get("login").asString().get();
cu.password = config.get("password").asString().orElse("").toCharArray();
cu.roles.addAll(config.get("roles").asList(String.class).orElse(CollectionsHelper.listOf()));
return cu;
}
代码示例来源:origin: oracle/helidon
private String aliased(String value, Config config) {
if (value.startsWith(PREFIX_ALIAS)) {
// another_password=${ALIAS=service_password}
String alias = removePlaceholder(PREFIX_ALIAS, value);
return config.get(alias).asString().orElseThrow(MissingValueException.createSupplier(Config.Key.create(alias)));
}
return value;
}
代码示例来源:origin: oracle/helidon
/**
* Read a new instance from configuration.
* The current node should contain a {@code "name"} and configuration for {@link TokenHandler}
*
* @param config configuration instance
* @return new query parameter handler instance
*/
public static QueryParamMapping create(Config config) {
String name = config.get("name").asString().get();
TokenHandler handler = config.as(TokenHandler::create).get();
return create(name, handler);
}
代码示例来源:origin: oracle/helidon
/**
* Update this builder from configuration.
*
* @param config config instance located on the key {@link PolicyValidator#configKey()}
* @return updated builder instance
*/
public Builder config(Config config) {
config.get("inherit").asBoolean().ifPresent(this::inherit);
config.get("statement").asString().ifPresent(this::statement);
return this;
}
代码示例来源:origin: oracle/helidon
static OutboundTarget create(Config c) {
Builder builder = new Builder();
builder.config(c);
builder.name(c.get(CONFIG_NAME).asString().get());
c.get(CONFIG_TRANSPORTS).asList(String.class).orElse(CollectionsHelper.listOf())
.forEach(builder::addTransport);
c.get(CONFIG_HOSTS).asList(String.class).orElse(CollectionsHelper.listOf())
.forEach(builder::addHost);
c.get(CONFIG_PATHS).asList(String.class).orElse(CollectionsHelper.listOf())
.forEach(builder::addPath);
return builder.build();
}
内容来源于网络,如有侵权,请联系作者删除!