package digital.laboratory.platform.entrustment.enums;

import lombok.Getter;

/**
 * 分析项目枚举
 */
@Getter
public enum AnalysisOptionEnums {

    QUALITATIVE(1, "定性", "qualitative"),

    RATION(2, "定量", "ration"),

    QUALITATIVE_AND_RATION(3, "定性定量", "qualitativeAndRation"),

    RELEVANCE(4, "关联性", "relevance"),

    OTHER(4, "其他", "other"),
    ;

    private final Integer code;

    private final String chineseName;

    private final String englishName;

    AnalysisOptionEnums(Integer code, String chineseName, String englishName) {
        this.code = code;
        this.chineseName = chineseName;
        this.englishName = englishName;
    }

    /**
     * 根据状态码获取对应的枚举值
     *
     * @param code 状态码
     * @return 对应的枚举值
     * @throws IllegalArgumentException 当给定的状态码没有对应的枚举值时抛出此异常
     */
    public static AnalysisOptionEnums fromCode(Integer code) {
        for (AnalysisOptionEnums analysisOptionEnums : values()) {
            if (analysisOptionEnums.getCode().equals(code)) {
                return analysisOptionEnums;
            }
        }
        throw new IllegalArgumentException("No enum constant with code: " + code);
    }
}
