本文整理了Java中io.helidon.config.Config.asNode()
方法的一些代码示例,展示了Config.asNode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.asNode()
方法的具体详情如下:
包路径:io.helidon.config.Config
类名称:Config
方法名:asNode
[英]Returns existing current config node as a Optional instance or Optional#empty() in case of Type#MISSING node.
[中]将现有的当前配置节点作为可选实例返回,如果类型#缺少节点,则返回可选的#empty()。
代码示例来源:origin: oracle/helidon
/**
* Performs the given action with the config node if node
* {@link #exists() exists}, otherwise does nothing.
*
* @param action the action to be performed if the node exists
* @see #exists()
* @see #type()
*/
default void ifExists(Consumer<Config> action) {
asNode().ifPresent(action);
}
代码示例来源:origin: oracle/helidon
public <T> Function<T, Supplier<PollingStrategy>> apply(Config config, Class<T> targetType)
throws ConfigMappingException, MissingValueException {
Config properties = config.get(PROPERTIES_KEY) // use properties config node
.asNode()
.orElse(Config.empty(config)); // or empty config node
return OptionalHelper.from(config.get(TYPE_KEY).asString() // `type` is specified
.flatMap(type -> this
.builtin(type, properties, targetType))) // return built-in polling strategy
.or(() -> config.get(CLASS_KEY)
.as(Class.class) // `class` is specified
.flatMap(clazz -> custom(clazz, properties, targetType))) // return custom polling strategy
.asOptional()
.orElseThrow(() -> new ConfigMappingException(config.key(), "Uncompleted polling-strategy configuration."));
}
代码示例来源:origin: oracle/helidon
@Override
public RetryPolicy apply(Config config) throws ConfigMappingException, MissingValueException {
Config properties = config.get(PROPERTIES_KEY) // use properties config node
.asNode()
.orElse(Config.empty(config)); // or empty config node
return OptionalHelper.from(config.get(TYPE_KEY).asString() // `type` is specified
.flatMap(type -> this.builtin(type, properties))) // return built-in retry policy
.or(() -> config.get(CLASS_KEY)
.as(Class.class) // `class` is specified
.flatMap(clazz -> custom(clazz, properties))) // return custom retry policy
.asOptional()
.orElseThrow(() -> new ConfigMappingException(config.key(), "Uncompleted retry-policy configuration."));
}
代码示例来源:origin: oracle/helidon
/**
* Update builder from configuration. See
* {@link JwtProvider.JwtOutboundTarget#create(Config, TokenHandler)}
* for configuration options description.
*
* @param config to update builder from
* @return updated builder instance
*/
public Builder config(Config config) {
config.get("outbound-token")
.asNode()
.map(TokenHandler::create)
.ifPresent(this::tokenHandler);
config.get("jwt-kid").asString().ifPresent(this::jwtKid);
config.get("jwk-kid").asString().ifPresent(this::jwkKid);
config.get("jwt-audience").asString().ifPresent(this::jwtAudience);
config.get("jwt-not-before-seconds").asInt().ifPresent(this::notBeforeSeconds);
config.get("jwt-validity-seconds").asLong().ifPresent(this::validitySeconds);
return this;
}
代码示例来源:origin: oracle/helidon
@Override
public ConfigSource apply(Config config) throws ConfigMappingException, MissingValueException {
Config properties = config.get(PROPERTIES_KEY) // use properties config node
.asNode()
.orElse(Config.empty(config)); // or empty config node
return OptionalHelper.from(config.get(TYPE_KEY)
.asString() // `type` is specified
.flatMap(type -> OptionalHelper
.from(builtin(type, properties)) // return built-in source
.or(() -> providers(type, properties))
.asOptional())) // or use sources - custom type to class mapping
.or(() -> config.get(CLASS_KEY)
.as(Class.class) // `class` is specified
.flatMap(clazz -> custom(clazz, properties))) // return custom source
.asOptional()
.orElseThrow(() -> new ConfigMappingException(config.key(), "Uncompleted source configuration."));
}
代码示例来源:origin: oracle/helidon
/**
* Load an instance from configuration.
* Expected keys:
* <ul>
* <li>jwt-kid - the key id to put into JWT</li>
* <li>jwk-kid - the key id to look for when signing the JWT</li>
* <li>jwt-audience - the audience of this JWT</li>
* <li>jwt-not-before-seconds - not before seconds</li>
* <li>jwt-validity-seconds - validity of JWT</li>
* </ul>
*
* @param config configuration to load data from
* @param defaultHandler default outbound token handler
* @return a new instance configured from config
* @see #JwtOutboundTarget(TokenHandler, String, String, String, int, long)
*/
public static JwtOutboundTarget fromConfig(Config config, TokenHandler defaultHandler) {
TokenHandler tokenHandler = config.get("outbound-token")
.asNode()
.map(TokenHandler::create)
.orElse(defaultHandler);
return new JwtOutboundTarget(
tokenHandler,
config.get("jwt-kid").asString().orElse(null),
config.get("jwk-kid").asString().orElse(null),
config.get("jwt-audience").asString().orElse(null),
config.get("jwt-not-before-seconds").asInt().orElse(5),
config.get("jwt-validity-seconds").asLong().orElse(60L * 60 * 24));
}
代码示例来源:origin: io.helidon.config/helidon-config
/**
* Performs the given action with the config node if node
* {@link #exists() exists}, otherwise does nothing.
*
* @param action the action to be performed if the node exists
* @see #exists()
* @see #type()
*/
default void ifExists(Consumer<Config> action) {
asNode().ifPresent(action);
}
代码示例来源:origin: io.helidon.config/helidon-config
@Override
public RetryPolicy apply(Config config) throws ConfigMappingException, MissingValueException {
Config properties = config.get(PROPERTIES_KEY) // use properties config node
.asNode()
.orElse(Config.empty(config)); // or empty config node
return OptionalHelper.from(config.get(TYPE_KEY).asString() // `type` is specified
.flatMap(type -> this.builtin(type, properties))) // return built-in retry policy
.or(() -> config.get(CLASS_KEY)
.as(Class.class) // `class` is specified
.flatMap(clazz -> custom(clazz, properties))) // return custom retry policy
.asOptional()
.orElseThrow(() -> new ConfigMappingException(config.key(), "Uncompleted retry-policy configuration."));
}
代码示例来源:origin: io.helidon.config/helidon-config
public <T> Function<T, Supplier<PollingStrategy>> apply(Config config, Class<T> targetType)
throws ConfigMappingException, MissingValueException {
Config properties = config.get(PROPERTIES_KEY) // use properties config node
.asNode()
.orElse(Config.empty(config)); // or empty config node
return OptionalHelper.from(config.get(TYPE_KEY).asString() // `type` is specified
.flatMap(type -> this
.builtin(type, properties, targetType))) // return built-in polling strategy
.or(() -> config.get(CLASS_KEY)
.as(Class.class) // `class` is specified
.flatMap(clazz -> custom(clazz, properties, targetType))) // return custom polling strategy
.asOptional()
.orElseThrow(() -> new ConfigMappingException(config.key(), "Uncompleted polling-strategy configuration."));
}
代码示例来源:origin: io.helidon.security.providers/helidon-security-providers-jwt
/**
* Update builder from configuration. See
* {@link JwtProvider.JwtOutboundTarget#create(Config, TokenHandler)}
* for configuration options description.
*
* @param config to update builder from
* @return updated builder instance
*/
public Builder config(Config config) {
config.get("outbound-token")
.asNode()
.map(TokenHandler::create)
.ifPresent(this::tokenHandler);
config.get("jwt-kid").asString().ifPresent(this::jwtKid);
config.get("jwk-kid").asString().ifPresent(this::jwkKid);
config.get("jwt-audience").asString().ifPresent(this::jwtAudience);
config.get("jwt-not-before-seconds").asInt().ifPresent(this::notBeforeSeconds);
config.get("jwt-validity-seconds").asLong().ifPresent(this::validitySeconds);
return this;
}
代码示例来源:origin: io.helidon.config/helidon-config
@Override
public ConfigSource apply(Config config) throws ConfigMappingException, MissingValueException {
Config properties = config.get(PROPERTIES_KEY) // use properties config node
.asNode()
.orElse(Config.empty(config)); // or empty config node
return OptionalHelper.from(config.get(TYPE_KEY)
.asString() // `type` is specified
.flatMap(type -> OptionalHelper
.from(builtin(type, properties)) // return built-in source
.or(() -> providers(type, properties))
.asOptional())) // or use sources - custom type to class mapping
.or(() -> config.get(CLASS_KEY)
.as(Class.class) // `class` is specified
.flatMap(clazz -> custom(clazz, properties))) // return custom source
.asOptional()
.orElseThrow(() -> new ConfigMappingException(config.key(), "Uncompleted source configuration."));
}
代码示例来源:origin: io.helidon.microprofile.jwt/helidon-microprofile-jwt-auth
/**
* Load an instance from configuration.
* Expected keys:
* <ul>
* <li>jwt-kid - the key id to put into JWT</li>
* <li>jwk-kid - the key id to look for when signing the JWT</li>
* <li>jwt-audience - the audience of this JWT</li>
* <li>jwt-not-before-seconds - not before seconds</li>
* <li>jwt-validity-seconds - validity of JWT</li>
* </ul>
*
* @param config configuration to load data from
* @param defaultHandler default outbound token handler
* @return a new instance configured from config
* @see #JwtOutboundTarget(TokenHandler, String, String, String, int, long)
*/
public static JwtOutboundTarget fromConfig(Config config, TokenHandler defaultHandler) {
TokenHandler tokenHandler = config.get("outbound-token")
.asNode()
.map(TokenHandler::create)
.orElse(defaultHandler);
return new JwtOutboundTarget(
tokenHandler,
config.get("jwt-kid").asString().orElse(null),
config.get("jwk-kid").asString().orElse(null),
config.get("jwt-audience").asString().orElse(null),
config.get("jwt-not-before-seconds").asInt().orElse(5),
config.get("jwt-validity-seconds").asLong().orElse(60L * 60 * 24));
}
内容来源于网络,如有侵权,请联系作者删除!