Example usage for org.springframework.boot.autoconfigure.condition ConditionOutcome match

List of usage examples for org.springframework.boot.autoconfigure.condition ConditionOutcome match

Introduction

In this page you can find the example usage for org.springframework.boot.autoconfigure.condition ConditionOutcome match.

Prototype

boolean match

To view the source code for org.springframework.boot.autoconfigure.condition ConditionOutcome match.

Click Source Link

Usage

From source file:io.fabric8.spring.boot.condition.OnKubernetesAvailableCondition.java

@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
    ConditionOutcome outcome = inside.getMatchOutcome(context, metadata);
    if (outcome.isMatch()) {
        return ConditionOutcome.noMatch("Inside condition match.");
    } else {//from   www.  j  a  v a  2s .  co  m
        return ConditionOutcome.match("Inside not matches, assuming external!");
    }
}

From source file:me.j360.trace.autoconfiguration.collector.kafka.KafkaZooKeeperSetCondition.java

@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata a) {
    String kafkaZookeeper = context.getEnvironment().getProperty(PROPERTY_NAME);
    return kafkaZookeeper == null || kafkaZookeeper.isEmpty()
            ? ConditionOutcome.noMatch(PROPERTY_NAME + " isn't set")
            : ConditionOutcome.match();
}

From source file:io.fabric8.spring.boot.condition.OnInsideKubernetesCondition.java

@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
    for (String variable : REQUIRED_ENV_VARIABLES) {
        if (Strings.isNullOrBlank(System.getenv().get(variable))) {
            return ConditionOutcome.noMatch("Environment variable " + variable + " not found.");
        }//from w w  w  .j  a  v a  2  s  . c o  m
    }
    return ConditionOutcome.match();
}

From source file:de.codecentric.boot.admin.config.SpringBootAdminClientEnabledCondition.java

@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata annotatedTypeMetadata) {

    if (!isEnabled(context.getEnvironment())) {
        return ConditionOutcome.noMatch(
                "Spring Boot Client is disabled, because 'spring.boot.admin.client.enabled' is false.");
    }/*from   w w  w  .j a  va2 s.c  o  m*/

    if (isUrlEmpty(context.getEnvironment())) {
        return ConditionOutcome
                .noMatch("Spring Boot Client is disabled, because 'spring.boot.admin.url' is empty.");
    }

    return ConditionOutcome.match();
}

From source file:org.juiser.spring.boot.config.JuiserSpringSecurityCondition.java

@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {

    ConditionMessage matchMessage = ConditionMessage.empty();

    boolean enabled = isSpringSecurityEnabled(context);

    if (metadata.isAnnotated(ConditionalOnJuiserSpringSecurityEnabled.class.getName())) {
        if (!enabled) {
            return ConditionOutcome
                    .noMatch(ConditionMessage.forCondition(ConditionalOnJuiserSpringSecurityEnabled.class)
                            .didNotFind("spring security enabled").atAll());
        }//  www .java  2s . c om
        matchMessage = matchMessage.andCondition(ConditionalOnJuiserSpringSecurityEnabled.class)
                .foundExactly("spring security enabled");
    }

    if (metadata.isAnnotated(ConditionalOnJuiserSpringSecurityDisabled.class.getName())) {
        if (enabled) {
            return ConditionOutcome
                    .noMatch(ConditionMessage.forCondition(ConditionalOnJuiserSpringSecurityDisabled.class)
                            .didNotFind("spring security disabled").atAll());
        }
        matchMessage = matchMessage.andCondition(ConditionalOnJuiserSpringSecurityDisabled.class)
                .didNotFind("spring security disabled").atAll();
    }

    return ConditionOutcome.match(matchMessage);
}

From source file:org.springframework.boot.autoconfigure.condition.OnBeanCondition.java

@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
    StringBuffer matchMessage = new StringBuffer();
    if (metadata.isAnnotated(ConditionalOnBean.class.getName())) {
        BeanSearchSpec spec = new BeanSearchSpec(context, metadata, ConditionalOnBean.class);
        List<String> matching = getMatchingBeans(context, spec);
        if (matching.isEmpty()) {
            return ConditionOutcome.noMatch("@ConditionalOnBean " + spec + " found no beans");
        }/*from w  w  w.j a  v a  2 s  .c  om*/
        matchMessage.append("@ConditionalOnBean " + spec + " found the following " + matching);
    }
    if (metadata.isAnnotated(ConditionalOnSingleCandidate.class.getName())) {
        BeanSearchSpec spec = new SingleCandidateBeanSearchSpec(context, metadata,
                ConditionalOnSingleCandidate.class);
        List<String> matching = getMatchingBeans(context, spec);
        if (matching.isEmpty()) {
            return ConditionOutcome.noMatch("@ConditionalOnSingleCandidate " + spec + " found no beans");
        } else if (!hasSingleAutowireCandidate(context.getBeanFactory(), matching)) {
            return ConditionOutcome.noMatch("@ConditionalOnSingleCandidate " + spec
                    + " found no primary candidate amongst the" + " following " + matching);
        }
        matchMessage.append("@ConditionalOnSingleCandidate " + spec + " found "
                + "a primary candidate amongst the following " + matching);
    }
    if (metadata.isAnnotated(ConditionalOnMissingBean.class.getName())) {
        BeanSearchSpec spec = new BeanSearchSpec(context, metadata, ConditionalOnMissingBean.class);
        List<String> matching = getMatchingBeans(context, spec);
        if (!matching.isEmpty()) {
            return ConditionOutcome
                    .noMatch("@ConditionalOnMissingBean " + spec + " found the following " + matching);
        }
        matchMessage.append(matchMessage.length() == 0 ? "" : " ");
        matchMessage.append("@ConditionalOnMissingBean " + spec + " found no beans");
    }
    return ConditionOutcome.match(matchMessage.toString());
}