package com.capgemini.reports.definition.r20report;

import lombok.extern.slf4j.Slf4j;

import java.util.Locale;

/**
 * Enumeration of the MajorMinor field's possible values.
 */
@Slf4j
public enum MajorMinor {
    /**
     * The value Major.
     */
    MAJOR {
        @Override
        public String toString() {
            return "Majeur";
        }
    },
    /**
     * The value Minor.
     */
    MINOR {
        @Override
        public String toString() {
            return "Mineur";
        }
    };

    /**
     * Parses an input {@link String} and returns the corresponding enum instance.<br>
     * Default value: Major
     *
     * @param majorMinorStr the input string
     * @return the instance
     */
    public static MajorMinor parse(final String majorMinorStr) {
        String majorMinorLC = majorMinorStr.toLowerCase(Locale.FRENCH);
        if ("majeur".equals(majorMinorLC)) {
            return MAJOR;
        } else {
            if ("mineur".equals(majorMinorLC)) {
                return MINOR;
            } else {
                log.warn("Could not decide between major and Minor for input '{}', defaulting to Major", majorMinorLC);
                return MAJOR;
            }
        }
    }
}
