class OnSwitchCondition extends SpringBootCondition {

    private static final String CONFIG_KEY_PREFIX = "sofa.boot.switch.bean";

    @Override
    public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
        return getMatchOutcome(context.getEnvironment(), metadata);
    }

    private ConditionOutcome getMatchOutcome(Environment environment, AnnotatedTypeMetadata metadata) {
        ConditionMessage.Builder message = ConditionMessage.forCondition(ConditionalOnSwitch.class);
        String key = getKey(metadata);
        Boolean userDefinedEnabled = environment.getProperty(key, Boolean.class);
        if (userDefinedEnabled != null) {
            return new ConditionOutcome(userDefinedEnabled, message.because("found property " + key
                                                                            + " with value "
                                                                            + userDefinedEnabled));
        }

        MergedAnnotation<ConditionalOnSwitch> conditionAnnotation = metadata.getAnnotations().get(
            ConditionalOnSwitch.class);
        Boolean matchIfMissing = conditionAnnotation.getBoolean("matchIfMissing");
        return new ConditionOutcome(matchIfMissing, message.because("matchIfMissing " + key
                                                                    + " with value "
                                                                    + matchIfMissing));
    }

    private String getKey(AnnotatedTypeMetadata metadata) {
        MergedAnnotation<ConditionalOnSwitch> conditionAnnotation = metadata.getAnnotations().get(
            ConditionalOnSwitch.class);
        String key = conditionAnnotation.getString("value");
        if (StringUtils.hasText(key)) {
            return CONFIG_KEY_PREFIX.concat(".").concat(key).concat(".enabled");
        } else {
            return CONFIG_KEY_PREFIX.concat(".").concat(getClassOrMethodName(metadata))
                .concat(".enabled");
        }
    }

    private String getClassOrMethodName(AnnotatedTypeMetadata metadata) {<FILL_FUNCTION_BODY>}
}

        if (metadata instanceof ClassMetadata classMetadata) {
            return classMetadata.getClassName();
        }
        MethodMetadata methodMetadata = (MethodMetadata) metadata;
        return methodMetadata.getMethodName();
    
<methods>public void <init>() ,public abstract org.springframework.boot.autoconfigure.condition.ConditionOutcome getMatchOutcome(org.springframework.context.annotation.ConditionContext, org.springframework.core.type.AnnotatedTypeMetadata) ,public final boolean matches(org.springframework.context.annotation.ConditionContext, org.springframework.core.type.AnnotatedTypeMetadata) <variables>private final org.apache.commons.logging.Log logger