io.micronaut.context.env.Environment.containsProperty()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(194)

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

Environment.containsProperty介绍

暂无

代码示例

代码示例来源:origin: micronaut-projects/micronaut-core

@Override
  public boolean matches(ConditionContext context) {
    AnnotationMetadataProvider component = context.getComponent();
    BeanContext beanContext = context.getBeanContext();

    if (beanContext instanceof ApplicationContext) {
      Environment env = ((ApplicationContext) beanContext).getEnvironment();
      if (component instanceof ValueResolver) {
        Optional<String> optional = ((ValueResolver) component).get(Named.class.getName(), String.class);
        if (optional.isPresent()) {
          String serviceName = optional.get();
          String urlProp = ServiceHttpClientConfiguration.PREFIX + "." + serviceName + ".url";
          return env.containsProperty(urlProp) || env.containsProperty(urlProp + "s");
        }
      }
    }
    return true;
  }
}

代码示例来源:origin: micronaut-projects/micronaut-spring

@Override
  public void validateRequiredProperties() throws MissingRequiredPropertiesException {
    if (requiredProperties != null) {
      Set<String> missingProps = new HashSet<>();
      for (String requiredProperty : requiredProperties) {
        if (!environment.containsProperty(requiredProperty)) {
          missingProps.add(requiredProperty);
        }
      }

      if (!missingProps.isEmpty()) {
        throw new MissingRequiredPropertiesException() {
          @Override
          public Set<String> getMissingRequiredProperties() {
            return missingProps;
          }
        };

      }
    }
  }
}

代码示例来源:origin: io.micronaut/micronaut-inject

@Override
public boolean containsProperty(String name) {
  return getEnvironment().containsProperty(name);
}

代码示例来源:origin: io.micronaut/inject

@Override
public boolean containsProperty(String name) {
  return getEnvironment().containsProperty(name);
}

代码示例来源:origin: micronaut-projects/micronaut-spring

@Override
public boolean containsProperty(String key) {
  return environment.containsProperty(key) || environment.containsProperties(key);
}

代码示例来源:origin: io.micronaut/http-client

@Override
  public boolean matches(ConditionContext context) {
    AnnotationMetadataProvider component = context.getComponent();
    BeanContext beanContext = context.getBeanContext();

    if (beanContext instanceof ApplicationContext) {
      Environment env = ((ApplicationContext) beanContext).getEnvironment();
      if (component instanceof ValueResolver) {
        Optional<String> optional = ((ValueResolver) component).get(Named.class.getName(), String.class);
        if (optional.isPresent()) {
          String serviceName = optional.get();
          String urlProp = ServiceHttpClientConfiguration.PREFIX + "." + serviceName + ".url";
          return env.containsProperty(urlProp) || env.containsProperty(urlProp + "s");
        }
      }
    }
    return true;
  }
}

代码示例来源:origin: io.micronaut/micronaut-http-client

@Override
  public boolean matches(ConditionContext context) {
    AnnotationMetadataProvider component = context.getComponent();
    BeanContext beanContext = context.getBeanContext();

    if (beanContext instanceof ApplicationContext) {
      Environment env = ((ApplicationContext) beanContext).getEnvironment();
      if (component instanceof ValueResolver) {
        Optional<String> optional = ((ValueResolver) component).get(Named.class.getName(), String.class);
        if (optional.isPresent()) {
          String serviceName = optional.get();
          String urlProp = ServiceHttpClientConfiguration.PREFIX + "." + serviceName + ".url";
          return env.containsProperty(urlProp) || env.containsProperty(urlProp + "s");
        }
      }
    }
    return true;
  }
}

相关文章