本文整理了Java中io.helidon.config.Config.ifExists()
方法的一些代码示例,展示了Config.ifExists()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.ifExists()
方法的具体详情如下:
包路径:io.helidon.config.Config
类名称:Config
方法名:ifExists
[英]Performs the given action with the config node if node #exists(), otherwise does nothing.
[中]如果节点#exists(),则使用配置节点执行给定操作,否则不执行任何操作。
代码示例来源:origin: oracle/helidon
/**
* Initialize builder from specified configuration properties.
* <p>
* Supported configuration {@code properties}:
* <ul>
* <li>{@code optional} - type {@code boolean}, see {@link #optional()}</li>
* <li>{@code polling-strategy} - see {@link PollingStrategy} for details about configuration format,
* see {@link #pollingStrategy(Supplier)} or {@link #pollingStrategy(Function)}</li>
* </ul>
*
* @param metaConfig configuration properties used to initialize a builder instance.
* @return modified builder instance
*/
protected B init(Config metaConfig) {
//optional / mandatory
metaConfig.get(OPTIONAL_KEY)
.asBoolean()
.filter(value -> value) //filter `true` only
.ifPresent(value -> optional());
//polling-strategy
metaConfig.get(POLLING_STRATEGY_KEY)
.ifExists(cfg -> pollingStrategy(PollingStrategyConfigMapper.instance().apply(cfg, targetType)));
//retry-policy
metaConfig.get(RETRY_POLICY_KEY)
.as(RetryPolicy::create)
.ifPresent(this::retryPolicy);
return thisBuilder;
}
代码示例来源:origin: oracle/helidon
/**
* Load this builder from a configuration.
*
* @param config configuration to load from
* @return updated builder instance
*/
public Builder config(Config config) {
config.get("optional").as(Boolean.class).ifPresent(this::optional);
config.get("authenticate").as(Boolean.class).ifPresent(this::authenticate);
config.get("propagate").as(Boolean.class).ifPresent(this::propagate);
config.get("allow-impersonation").asBoolean().ifPresent(this::allowImpersonation);
config.get("principal-type").as(SubjectType.class).ifPresent(this::subjectType);
config.get("atn-token.handler").as(TokenHandler.class).ifPresent(this::atnTokenHandler);
config.get("atn-token").ifExists(this::verifyKeys);
config.get("atn-token.jwt-audience").asString().ifPresent(this::expectedAudience);
config.get("sign-token").ifExists(outbound -> outboundConfig(OutboundConfig.create(outbound)));
config.get("sign-token").ifExists(this::outbound);
return this;
}
代码示例来源:origin: oracle/helidon
/**
* Load this builder from a configuration.
*
* @param config configuration to load from
* @return updated builder instance
*/
public Builder config(Config config) {
config.get("optional").asBoolean().ifPresent(this::optional);
config.get("authenticate").asBoolean().ifPresent(this::authenticate);
config.get("propagate").asBoolean().ifPresent(this::propagate);
config.get("allow-impersonation").asBoolean().ifPresent(this::allowImpersonation);
config.get("principal-type").asString().as(SubjectType::valueOf).ifPresent(this::subjectType);
config.get("atn-token.handler").as(TokenHandler::create).ifPresent(this::atnTokenHandler);
config.get("atn-token").ifExists(this::verifyKeys);
config.get("atn-token.jwt-audience").asString().ifPresent(this::expectedAudience);
config.get("atn-token.default-key-id").asString().ifPresent(this::defaultKeyId);
config.get("atn-token.verify-key").asString().ifPresent(this::publicKeyPath);
config.get("sign-token").ifExists(outbound -> outboundConfig(OutboundConfig.create(outbound)));
config.get("sign-token").ifExists(this::outbound);
org.eclipse.microprofile.config.Config mpConfig = ConfigProviderResolver.instance().getConfig();
mpConfig.getOptionalValue(CONFIG_PUBLIC_KEY, String.class).ifPresent(this::publicKey);
mpConfig.getOptionalValue(CONFIG_PUBLIC_KEY_PATH, String.class).ifPresent(this::publicKeyPath);
mpConfig.getOptionalValue(CONFIG_EXPECTED_ISSUER, String.class).ifPresent(this::expectedIssuer);
return this;
}
代码示例来源:origin: oracle/helidon
});
serverConfig.get("static.classpath").ifExists(cpConfig -> {
Config context = cpConfig.get("context");
serverConfig.get("static.path").ifExists(pathConfig -> {
Config context = pathConfig.get("context");
StaticContentSupport.Builder pBuilder = StaticContentSupport.builder(pathConfig.get("location").as(Path.class).get());
代码示例来源:origin: io.helidon.config/helidon-config
/**
* Initialize builder from specified configuration properties.
* <p>
* Supported configuration {@code properties}:
* <ul>
* <li>{@code optional} - type {@code boolean}, see {@link #optional()}</li>
* <li>{@code polling-strategy} - see {@link PollingStrategy} for details about configuration format,
* see {@link #pollingStrategy(Supplier)} or {@link #pollingStrategy(Function)}</li>
* </ul>
*
* @param metaConfig configuration properties used to initialize a builder instance.
* @return modified builder instance
*/
protected B init(Config metaConfig) {
//optional / mandatory
metaConfig.get(OPTIONAL_KEY)
.asBoolean()
.filter(value -> value) //filter `true` only
.ifPresent(value -> optional());
//polling-strategy
metaConfig.get(POLLING_STRATEGY_KEY)
.ifExists(cfg -> pollingStrategy(PollingStrategyConfigMapper.instance().apply(cfg, targetType)));
//retry-policy
metaConfig.get(RETRY_POLICY_KEY)
.as(RetryPolicy::create)
.ifPresent(this::retryPolicy);
return thisBuilder;
}
代码示例来源:origin: io.helidon.security.providers/helidon-security-providers-jwt
/**
* Load this builder from a configuration.
*
* @param config configuration to load from
* @return updated builder instance
*/
public Builder config(Config config) {
config.get("optional").as(Boolean.class).ifPresent(this::optional);
config.get("authenticate").as(Boolean.class).ifPresent(this::authenticate);
config.get("propagate").as(Boolean.class).ifPresent(this::propagate);
config.get("allow-impersonation").asBoolean().ifPresent(this::allowImpersonation);
config.get("principal-type").as(SubjectType.class).ifPresent(this::subjectType);
config.get("atn-token.handler").as(TokenHandler.class).ifPresent(this::atnTokenHandler);
config.get("atn-token").ifExists(this::verifyKeys);
config.get("atn-token.jwt-audience").asString().ifPresent(this::expectedAudience);
config.get("sign-token").ifExists(outbound -> outboundConfig(OutboundConfig.create(outbound)));
config.get("sign-token").ifExists(this::outbound);
return this;
}
代码示例来源:origin: io.helidon.microprofile.jwt/helidon-microprofile-jwt-auth
/**
* Load this builder from a configuration.
*
* @param config configuration to load from
* @return updated builder instance
*/
public Builder config(Config config) {
config.get("optional").asBoolean().ifPresent(this::optional);
config.get("authenticate").asBoolean().ifPresent(this::authenticate);
config.get("propagate").asBoolean().ifPresent(this::propagate);
config.get("allow-impersonation").asBoolean().ifPresent(this::allowImpersonation);
config.get("principal-type").asString().as(SubjectType::valueOf).ifPresent(this::subjectType);
config.get("atn-token.handler").as(TokenHandler::create).ifPresent(this::atnTokenHandler);
config.get("atn-token").ifExists(this::verifyKeys);
config.get("atn-token.jwt-audience").asString().ifPresent(this::expectedAudience);
config.get("atn-token.default-key-id").asString().ifPresent(this::defaultKeyId);
config.get("atn-token.verify-key").asString().ifPresent(this::publicKeyPath);
config.get("sign-token").ifExists(outbound -> outboundConfig(OutboundConfig.create(outbound)));
config.get("sign-token").ifExists(this::outbound);
org.eclipse.microprofile.config.Config mpConfig = ConfigProviderResolver.instance().getConfig();
mpConfig.getOptionalValue(CONFIG_PUBLIC_KEY, String.class).ifPresent(this::publicKey);
mpConfig.getOptionalValue(CONFIG_PUBLIC_KEY_PATH, String.class).ifPresent(this::publicKeyPath);
mpConfig.getOptionalValue(CONFIG_EXPECTED_ISSUER, String.class).ifPresent(this::expectedIssuer);
return this;
}
代码示例来源:origin: io.helidon.microprofile.server/helidon-microprofile-server
});
serverConfig.get("static.classpath").ifExists(cpConfig -> {
Config context = cpConfig.get("context");
serverConfig.get("static.path").ifExists(pathConfig -> {
Config context = pathConfig.get("context");
StaticContentSupport.Builder pBuilder = StaticContentSupport.builder(pathConfig.get("location").as(Path.class).get());
内容来源于网络,如有侵权,请联系作者删除!