package com.qmth.paper.library.common.enums;

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

/**
 * 识别方式
 */
public enum RecognitionTypeEnum {

    OCR("OCR识别"),

    BAR_CODE("条码识别"),
//    NONE("不识别")
    ;

    private String desc;

    private RecognitionTypeEnum(String desc) {
        this.desc = desc;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 状态转换 toName
     *
     * @param title
     * @return
     */
    public static String convertToName(String title) {
        for (RecognitionTypeEnum e : RecognitionTypeEnum.values()) {
            if (Objects.equals(title, e.getDesc())) {
                return e.name();
            }
        }
        return null;
    }

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

}
