package com.ruoyi.enums;

import com.google.common.collect.Maps;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;

@AllArgsConstructor
@Getter
public enum PaperBuildStatus {
    Init(10, "未定向未组卷"), Build(20, "未组卷"), Exam(30, "组卷未完成"), Finish(40, "组卷已完成");

    private final Integer val;
    private final String title;

    private static final Map<String, PaperBuildStatus> valMap = Maps.newHashMap();

    public static PaperBuildStatus of(Integer vol) {
        return valMap.get(vol.toString());
    }

    public static PaperBuildStatus of(String vol) {
        PaperBuildStatus type = valMap.get(vol);
        return null == type ? PaperBuildStatus.Init : type;
    }

    static {
        Arrays.stream(PaperBuildStatus.values()).forEach(t -> {
            valMap.put(t.val.toString(), t);
            valMap.put(t.title, t);
            valMap.put(t.name(), t);
        });
    }
}
