<commit_before>/*
 * Copyright 2014-2015 Hewlett-Packard Development Company, L.P.
 * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
 */

package com.hp.autonomy.frontend.find.configuration;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

public abstract class AbstractPersistentStateCondition implements Condition {

    private static final String DEFAULT_VALUE = "REDIS";

    private final PersistentStateConfig persistentStateConfig;

    protected AbstractPersistentStateCondition(final PersistentStateConfig persistentStateConfig) {
        this.persistentStateConfig = persistentStateConfig;
    }

    @Override
    public boolean matches(final ConditionContext context, final AnnotatedTypeMetadata metadata) {
        return getProperty(context) == persistentStateConfig;
    }

    private PersistentStateConfig getProperty(final ConditionContext context) {
        return PersistentStateConfig.valueOf(context.getEnvironment().getProperty("hp.find.persistentState", DEFAULT_VALUE));
    }<commit_msg>Use the enum constant as the default value<commit_after>/*
 * Copyright 2014-2015 Hewlett-Packard Development Company, L.P.
 * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
 */

package com.hp.autonomy.frontend.find.configuration;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

public abstract class AbstractPersistentStateCondition implements Condition {

    private static final PersistentStateConfig DEFAULT_VALUE = PersistentStateConfig.REDIS;

    private final PersistentStateConfig persistentStateConfig;

    protected AbstractPersistentStateCondition(final PersistentStateConfig persistentStateConfig) {
        this.persistentStateConfig = persistentStateConfig;
    }

    @Override
    public boolean matches(final ConditionContext context, final AnnotatedTypeMetadata metadata) {
        return getProperty(context) == persistentStateConfig;
    }

    private PersistentStateConfig getProperty(final ConditionContext context) {
        return PersistentStateConfig.valueOf(context.getEnvironment().getProperty("hp.find.persistentState", DEFAULT_VALUE.name()));
    }
{'fraction_non_alphanumeric': 0.06808169803764517, 'fraction_numerical': 0.006407689227072487, 'mean_word_length': 5.438144329896907, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7064581', 'n_tokens_mistral': 593, 'n_tokens_neox': 567, 'n_words': 159}