package cn.com.qmth.examcloud.core.questions.base.enums;

import org.apache.commons.lang3.StringUtils;

public enum ExportTemplateType {

    PAPER_EXPORT("PAPER_EXPORT", "试卷导出"),

    ANWSER_EXPORT("ANWSER_EXPORT", "答案导出"), OUTLINE_PAPER_EXPORT("OUTLINE_PAPER_EXPORT",
            "离线试卷"), PAPER_VIEW("PAPER_VIEW", "试卷预览"),

    ANWSER_VIEW("ANWSER_VIEW", "答案预览");

    private ExportTemplateType(String code, String name) {
        this.code = code;
        this.name = name;
    }

    private String code;

    private String name;

    public String getName() {
        return name;
    }

    ExportTemplateType(String name) {
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public static boolean checkCode(String v) {
        if (StringUtils.isBlank(v)) {
            return false;
        }
        for (ExportTemplateType e : ExportTemplateType.values()) {
            if (e.getCode().equals(v)) {
                return true;
            }
        }
        return false;
    }

    public static String getName(String v) {
        if (StringUtils.isBlank(v)) {
            return null;
        }
        for (ExportTemplateType e : ExportTemplateType.values()) {
            if (e.getCode().equals(v)) {
                return e.getName();
            }
        }
        return null;
    }
}
