<commit_before>package com.technologyconversations.bdd.steps;

import com.technologyconversations.bdd.steps.util.BddVariable;
import org.jbehave.core.annotations.AsParameterConverter;

import java.util.TreeMap;
import java.util.logging.Logger;

public class CommonSteps {

    public Logger getLogger() {
        return Logger.getLogger(this.getClass().getName());
    }

    private static TreeMap<String, String> variableMap;
    protected static TreeMap<String, String> getVariableMap() {
        if (variableMap == null) {
            variableMap = new TreeMap<>();
        }
        return variableMap;
    }
    protected void setVariableMap(final TreeMap<String, String> value) {
        variableMap = value;
    }
    public void addVariable(String key, String value) {
        getVariableMap().put(key, value);
    }
    public String getVariable(String key) {
        return getVariableMap().get(key);
    }

    public static String replaceTextWithVariableValues(final String text) {
        if (text != null) {
            String output = text;
            if (text.contains("@")) {
                for (String key : getVariableMap().descendingKeySet()) {
                    output = output.replace("@" + key, getVariableMap().get(key));
                }
            }
            return output;
        } else {
            return null;
        }
    }

    @AsParameterConverter
    public BddVariable createBddVariable(String value){
        return new BddVariable(value);
    }

}<commit_msg>Refactoring<commit_after>package com.technologyconversations.bdd.steps;

import com.technologyconversations.bdd.steps.util.BddDescription;
import com.technologyconversations.bdd.steps.util.BddVariable;
import org.jbehave.core.annotations.AsParameterConverter;
import org.jbehave.core.annotations.Given;

import java.util.TreeMap;

public class CommonSteps {

    private static TreeMap<String, String> variableMap;
    protected static TreeMap<String, String> getVariableMap() {
        if (variableMap == null) {
            variableMap = new TreeMap<>();
        }
        return variableMap;
    }
    protected void setVariableMap(final TreeMap<String, String> value) {
        variableMap = value;
    }
    @BddDescription("Adds variable with the specified key. " +
            "Variables can be referenced using @KEY format. " +
            "For example, if variable username has value my_user, " +
            "text 'Then Web element username should have text @username' would be transformed to: " +
            "'Then Web element username should have text my_user'.")
    @Given("variable $key has value $value")
    public void addVariable(String key, String value) {
        getVariableMap().put(key, value);
    }
    public String getVariable(String key) {
        return getVariableMap().get(key);
    }

    public static String replaceTextWithVariableValues(final String text) {
        if (text != null) {
            String output = text;
            if (text.contains("@")) {
                for (String key : getVariableMap().descendingKeySet()) {
                    output = output.replace("@" + key, getVariableMap().get(key));
                }
            }
            return output;
        } else {
            return null;
        }
    }

    @AsParameterConverter
    public BddVariable createBddVariable(String value){
        return new BddVariable(value);
    }

}
{'fraction_non_alphanumeric': 0.0994718309859155, 'fraction_numerical': 0.0, 'mean_word_length': 2.528985507246377, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '679501', 'n_tokens_mistral': 919, 'n_tokens_neox': 895, 'n_words': 230}