@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { String[] enablers = context.getBeanFactory().getBeanNamesForAnnotation(EnableOAuth2Client.class); boolean extensions = Arrays.stream(enablers) .filter(name -> !context.getBeanFactory().getType(name).equals(OAuthSecurityConfig.class)) .anyMatch(name -> context.getBeanFactory().isTypeMatch(name, OAuthSecurityConfig.class)); if (extensions) { return ConditionOutcome.noMatch("found @EnableOAuth2Client on a OAuthSecurityConfig subclass"); } else { return ConditionOutcome.match("found no @EnableOAuth2Client on a OAuthSecurityConfig subsclass"); } }