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

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

Introduction

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

Prototype

public static ConditionOutcome noMatch(ConditionMessage message) 

Source Link

Document

Create a new ConditionOutcome instance for 'no match'.

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 {//  w ww.  j  a  v  a 2 s . co m
        return ConditionOutcome.match("Inside not matches, assuming external!");
    }
}

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 ww  .  j  ava  2  s.com
    }
    return ConditionOutcome.match();
}

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();// w  w  w .  j  a  v a2 s.c o m
}

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.");
    }/*w  ww.j  a v a  2 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());
        }//w  w w.j  ava 2 s  .c o  m
        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");
        }// w w w  .  jav a 2s . co m
        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());
}