package com.qmth.distributed.print.business.enums;

import com.qmth.teachcloud.common.enums.EnumResult;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * 试卷备份方式
 *
 * @Date: 2021/3/23.
 */
public enum BackupMethodEnum {

    PLACE("按考点"),
    ROOM("按考场");

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

    private String name;

    public String getName() {
        return name;
    }

    /**
     * @return
     */
    public static List<EnumResult> listTypes() {
        List<EnumResult> list = new ArrayList<EnumResult>();
        for (BackupMethodEnum value : BackupMethodEnum.values()) {
            EnumResult result = new EnumResult();
            result.setCode(value.name());
            result.setName(value.getName());
            result.setOrdinal(value.ordinal());
            list.add(result);
        }
        return list;
    }

    public static String convertToName(String desc) {
        for (BackupMethodEnum e : BackupMethodEnum.values()) {
            if (Objects.equals(desc, e.getName())) {
                return e.name();
            }
        }
        return null;
    }

    public static BackupMethodEnum convertToEnum(String desc) {
        for (BackupMethodEnum e : BackupMethodEnum.values()) {
            if (Objects.equals(desc, e.getName())) {
                return e;
            }
        }
        return null;
    }

}
