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

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

Introduction

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

Prototype

public boolean isMatch() 

Source Link

Document

Return true if the outcome was a 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 w w  . ja  va  2 s .  c  o  m
        return ConditionOutcome.match("Inside not matches, assuming external!");
    }
}

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

@Override
public final boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
    String classOrMethodName = getClassOrMethodName(metadata);
    try {/*from  www  .  j a va  2  s . c om*/
        ConditionOutcome outcome = getMatchOutcome(context, metadata);
        logOutcome(classOrMethodName, outcome);
        recordEvaluation(context, classOrMethodName, outcome);
        return outcome.isMatch();
    } catch (NoClassDefFoundError ex) {
        throw new IllegalStateException("Could not evaluate condition on " + classOrMethodName
                + " due to internal class not found. " + "This can happen if you are @ComponentScanning a "
                + "springframework package (e.g. if you put a @ComponentScan "
                + "in the default package by mistake)", ex);
    } catch (RuntimeException ex) {
        throw new IllegalStateException("Error processing condition on " + getName(metadata), ex);
    }
}

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

private StringBuilder getLogMessage(String classOrMethodName, ConditionOutcome outcome) {
    StringBuilder message = new StringBuilder();
    message.append("Condition ");
    message.append(ClassUtils.getShortName(getClass()));
    message.append(" on ");
    message.append(classOrMethodName);/*from  w ww . ja  v a 2s.  com*/
    message.append(outcome.isMatch() ? " matched" : " did not match");
    if (StringUtils.hasLength(outcome.getMessage())) {
        message.append(" due to ");
        message.append(outcome.getMessage());
    }
    return message;
}