package cn.com.qmth.stmms.biz.file.enums;

/**
 * 所有管理的文件类型
 */
public enum FileType {

    SHEET("原图", "sheet/%d/%s/%s-%d.%s"), SLICE("裁切图", "slice/%d/%s/%s-%d.%s"), JSON("作答内容", "json/%d/%s/%s.%s"), PACKAGE(
            "签到表", "package/%d/%s/%d.%s"), PAPER("试卷", "paper/%d/%s.%s"), ANSWER("标答", "answer/%d/%s.%s"), CARD("题卡",
            "card/%d/%s.%s"), EXCHANGE("文件", "exchange/%s"), ANSWER_CARD("题卡", "card/answer/%d/%s.%s"), REPORT("报表",
            "report/%d/%s/%s.%s"), INCOMPLETE("缺页异常表", "incomplete/%d/%s.%s");

    private String name;

    private String pattern;

    private FileType(String name, String pattern) {
        this.name = name;
        this.pattern = pattern;
    }

    public String getName() {
        return name;
    }

    public String getPattern() {
        return pattern;
    }

    public boolean equals(String type) {
        return toString().equalsIgnoreCase(type);
    }

    public static FileType findByText(String text) {
        for (FileType type : values()) {
            if (type.equals(text)) {
                return type;
            }
        }
        return null;
    }

    public String getPath(Object... param) {
        return String.format(pattern, param);
    }

}
