<commit_before>package com.guigarage.lessfx.converters;

import com.sun.javafx.css.SizeUnits;
import javafx.css.StyleConverter;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author <NAME>
 * @since 2015-01-14
 */
public abstract class LessStyleConverter<F, T> extends StyleConverter<F, T> {
    protected LessStyleConverter() {
        super();
    }

    protected Matcher getMatcher(String value, String regex) {
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(value);
        if (matcher.find()) {
            return matcher;
        } else {
            return null;
        }
    }

    protected SizeUnits getUnit(String unit) {
        if (unit == null) {
            return null;
        }
        switch (unit.toLowerCase()) {
            case "%":
                return SizeUnits.PERCENT;
            case "in":
                return SizeUnits.IN;
            case "cm":
                return SizeUnits.CM;
            case "mm":
                return SizeUnits.MM;
            case "em":
                return SizeUnits.EM;
            case "ex":
                return SizeUnits.EX;
            case "pt":
                return SizeUnits.PT;
            case "pc":
                return SizeUnits.PC;
            case "px":
                return SizeUnits.PX;
            case "grad":
                return SizeUnits.GRAD;
            case "deg":
                return SizeUnits.DEG;
            case "rad":
                return SizeUnits.RAD;
            case "turn":
                return SizeUnits.TURN;
            default:
                return null;
        }
    }

    protected String getUnitRegex() {
        return "(%|in|cm|mm|em|ex|pt|pc|px|grad|deg|rad|turn)?";
    }
}<commit_msg>The SizeUnits enum is now used for converting the units as a straing to the proper enum value.<commit_after>package com.guigarage.lessfx.converters;

import com.sun.javafx.css.SizeUnits;
import javafx.css.StyleConverter;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author <NAME>
 * @since 2015-01-14
 */
public abstract class LessStyleConverter<F, T> extends StyleConverter<F, T> {
    protected LessStyleConverter() {
        super();
    }

    protected Matcher getMatcher(String value, String regex) {
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(value);
        if (matcher.find()) {
            return matcher;
        } else {
            return null;
        }
    }

    protected SizeUnits getUnit(String unit) {
        if (unit == null) {
            return null;
        } else if (unit.equals("")){
            return null;
        } else {
            return SizeUnits.valueOf(unit.equals("%") ? "PERCENT" : unit.toUpperCase());
        }
    }

    protected String getUnitRegex() {
        return "(%|in|cm|mm|em|ex|pt|pc|px|grad|deg|rad|turn)?";
    }
}
{'fraction_non_alphanumeric': 0.11118667120027202, 'fraction_numerical': 0.005440326419585175, 'mean_word_length': 1.7728557964184732, 'pattern_counts': {'":': 13, '<': 9, '<?xml version=': 0, '>': 9, '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': '1793716', 'n_tokens_mistral': 862, 'n_tokens_neox': 845, 'n_words': 199}