io.helidon.config.Config.ifExists()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(137)

本文整理了Java中io.helidon.config.Config.ifExists()方法的一些代码示例,展示了Config.ifExists()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.ifExists()方法的具体详情如下:
包路径:io.helidon.config.Config
类名称:Config
方法名:ifExists

Config.ifExists介绍

[英]Performs the given action with the config node if node #exists(), otherwise does nothing.
[中]如果节点#exists(),则使用配置节点执行给定操作,否则不执行任何操作。

代码示例

代码示例来源:origin: oracle/helidon

  1. /**
  2. * Initialize builder from specified configuration properties.
  3. * <p>
  4. * Supported configuration {@code properties}:
  5. * <ul>
  6. * <li>{@code optional} - type {@code boolean}, see {@link #optional()}</li>
  7. * <li>{@code polling-strategy} - see {@link PollingStrategy} for details about configuration format,
  8. * see {@link #pollingStrategy(Supplier)} or {@link #pollingStrategy(Function)}</li>
  9. * </ul>
  10. *
  11. * @param metaConfig configuration properties used to initialize a builder instance.
  12. * @return modified builder instance
  13. */
  14. protected B init(Config metaConfig) {
  15. //optional / mandatory
  16. metaConfig.get(OPTIONAL_KEY)
  17. .asBoolean()
  18. .filter(value -> value) //filter `true` only
  19. .ifPresent(value -> optional());
  20. //polling-strategy
  21. metaConfig.get(POLLING_STRATEGY_KEY)
  22. .ifExists(cfg -> pollingStrategy(PollingStrategyConfigMapper.instance().apply(cfg, targetType)));
  23. //retry-policy
  24. metaConfig.get(RETRY_POLICY_KEY)
  25. .as(RetryPolicy::create)
  26. .ifPresent(this::retryPolicy);
  27. return thisBuilder;
  28. }

代码示例来源:origin: oracle/helidon

  1. /**
  2. * Load this builder from a configuration.
  3. *
  4. * @param config configuration to load from
  5. * @return updated builder instance
  6. */
  7. public Builder config(Config config) {
  8. config.get("optional").as(Boolean.class).ifPresent(this::optional);
  9. config.get("authenticate").as(Boolean.class).ifPresent(this::authenticate);
  10. config.get("propagate").as(Boolean.class).ifPresent(this::propagate);
  11. config.get("allow-impersonation").asBoolean().ifPresent(this::allowImpersonation);
  12. config.get("principal-type").as(SubjectType.class).ifPresent(this::subjectType);
  13. config.get("atn-token.handler").as(TokenHandler.class).ifPresent(this::atnTokenHandler);
  14. config.get("atn-token").ifExists(this::verifyKeys);
  15. config.get("atn-token.jwt-audience").asString().ifPresent(this::expectedAudience);
  16. config.get("sign-token").ifExists(outbound -> outboundConfig(OutboundConfig.create(outbound)));
  17. config.get("sign-token").ifExists(this::outbound);
  18. return this;
  19. }

代码示例来源:origin: oracle/helidon

  1. /**
  2. * Load this builder from a configuration.
  3. *
  4. * @param config configuration to load from
  5. * @return updated builder instance
  6. */
  7. public Builder config(Config config) {
  8. config.get("optional").asBoolean().ifPresent(this::optional);
  9. config.get("authenticate").asBoolean().ifPresent(this::authenticate);
  10. config.get("propagate").asBoolean().ifPresent(this::propagate);
  11. config.get("allow-impersonation").asBoolean().ifPresent(this::allowImpersonation);
  12. config.get("principal-type").asString().as(SubjectType::valueOf).ifPresent(this::subjectType);
  13. config.get("atn-token.handler").as(TokenHandler::create).ifPresent(this::atnTokenHandler);
  14. config.get("atn-token").ifExists(this::verifyKeys);
  15. config.get("atn-token.jwt-audience").asString().ifPresent(this::expectedAudience);
  16. config.get("atn-token.default-key-id").asString().ifPresent(this::defaultKeyId);
  17. config.get("atn-token.verify-key").asString().ifPresent(this::publicKeyPath);
  18. config.get("sign-token").ifExists(outbound -> outboundConfig(OutboundConfig.create(outbound)));
  19. config.get("sign-token").ifExists(this::outbound);
  20. org.eclipse.microprofile.config.Config mpConfig = ConfigProviderResolver.instance().getConfig();
  21. mpConfig.getOptionalValue(CONFIG_PUBLIC_KEY, String.class).ifPresent(this::publicKey);
  22. mpConfig.getOptionalValue(CONFIG_PUBLIC_KEY_PATH, String.class).ifPresent(this::publicKeyPath);
  23. mpConfig.getOptionalValue(CONFIG_EXPECTED_ISSUER, String.class).ifPresent(this::expectedIssuer);
  24. return this;
  25. }

代码示例来源:origin: oracle/helidon

  1. });
  2. serverConfig.get("static.classpath").ifExists(cpConfig -> {
  3. Config context = cpConfig.get("context");
  4. serverConfig.get("static.path").ifExists(pathConfig -> {
  5. Config context = pathConfig.get("context");
  6. StaticContentSupport.Builder pBuilder = StaticContentSupport.builder(pathConfig.get("location").as(Path.class).get());

代码示例来源:origin: io.helidon.config/helidon-config

  1. /**
  2. * Initialize builder from specified configuration properties.
  3. * <p>
  4. * Supported configuration {@code properties}:
  5. * <ul>
  6. * <li>{@code optional} - type {@code boolean}, see {@link #optional()}</li>
  7. * <li>{@code polling-strategy} - see {@link PollingStrategy} for details about configuration format,
  8. * see {@link #pollingStrategy(Supplier)} or {@link #pollingStrategy(Function)}</li>
  9. * </ul>
  10. *
  11. * @param metaConfig configuration properties used to initialize a builder instance.
  12. * @return modified builder instance
  13. */
  14. protected B init(Config metaConfig) {
  15. //optional / mandatory
  16. metaConfig.get(OPTIONAL_KEY)
  17. .asBoolean()
  18. .filter(value -> value) //filter `true` only
  19. .ifPresent(value -> optional());
  20. //polling-strategy
  21. metaConfig.get(POLLING_STRATEGY_KEY)
  22. .ifExists(cfg -> pollingStrategy(PollingStrategyConfigMapper.instance().apply(cfg, targetType)));
  23. //retry-policy
  24. metaConfig.get(RETRY_POLICY_KEY)
  25. .as(RetryPolicy::create)
  26. .ifPresent(this::retryPolicy);
  27. return thisBuilder;
  28. }

代码示例来源:origin: io.helidon.security.providers/helidon-security-providers-jwt

  1. /**
  2. * Load this builder from a configuration.
  3. *
  4. * @param config configuration to load from
  5. * @return updated builder instance
  6. */
  7. public Builder config(Config config) {
  8. config.get("optional").as(Boolean.class).ifPresent(this::optional);
  9. config.get("authenticate").as(Boolean.class).ifPresent(this::authenticate);
  10. config.get("propagate").as(Boolean.class).ifPresent(this::propagate);
  11. config.get("allow-impersonation").asBoolean().ifPresent(this::allowImpersonation);
  12. config.get("principal-type").as(SubjectType.class).ifPresent(this::subjectType);
  13. config.get("atn-token.handler").as(TokenHandler.class).ifPresent(this::atnTokenHandler);
  14. config.get("atn-token").ifExists(this::verifyKeys);
  15. config.get("atn-token.jwt-audience").asString().ifPresent(this::expectedAudience);
  16. config.get("sign-token").ifExists(outbound -> outboundConfig(OutboundConfig.create(outbound)));
  17. config.get("sign-token").ifExists(this::outbound);
  18. return this;
  19. }

代码示例来源:origin: io.helidon.microprofile.jwt/helidon-microprofile-jwt-auth

  1. /**
  2. * Load this builder from a configuration.
  3. *
  4. * @param config configuration to load from
  5. * @return updated builder instance
  6. */
  7. public Builder config(Config config) {
  8. config.get("optional").asBoolean().ifPresent(this::optional);
  9. config.get("authenticate").asBoolean().ifPresent(this::authenticate);
  10. config.get("propagate").asBoolean().ifPresent(this::propagate);
  11. config.get("allow-impersonation").asBoolean().ifPresent(this::allowImpersonation);
  12. config.get("principal-type").asString().as(SubjectType::valueOf).ifPresent(this::subjectType);
  13. config.get("atn-token.handler").as(TokenHandler::create).ifPresent(this::atnTokenHandler);
  14. config.get("atn-token").ifExists(this::verifyKeys);
  15. config.get("atn-token.jwt-audience").asString().ifPresent(this::expectedAudience);
  16. config.get("atn-token.default-key-id").asString().ifPresent(this::defaultKeyId);
  17. config.get("atn-token.verify-key").asString().ifPresent(this::publicKeyPath);
  18. config.get("sign-token").ifExists(outbound -> outboundConfig(OutboundConfig.create(outbound)));
  19. config.get("sign-token").ifExists(this::outbound);
  20. org.eclipse.microprofile.config.Config mpConfig = ConfigProviderResolver.instance().getConfig();
  21. mpConfig.getOptionalValue(CONFIG_PUBLIC_KEY, String.class).ifPresent(this::publicKey);
  22. mpConfig.getOptionalValue(CONFIG_PUBLIC_KEY_PATH, String.class).ifPresent(this::publicKeyPath);
  23. mpConfig.getOptionalValue(CONFIG_EXPECTED_ISSUER, String.class).ifPresent(this::expectedIssuer);
  24. return this;
  25. }

代码示例来源:origin: io.helidon.microprofile.server/helidon-microprofile-server

  1. });
  2. serverConfig.get("static.classpath").ifExists(cpConfig -> {
  3. Config context = cpConfig.get("context");
  4. serverConfig.get("static.path").ifExists(pathConfig -> {
  5. Config context = pathConfig.get("context");
  6. StaticContentSupport.Builder pBuilder = StaticContentSupport.builder(pathConfig.get("location").as(Path.class).get());

相关文章