package cn.com.qmth.stmms.ms.core.domain.enums;

import java.util.Objects;

/**
 * @Description: 试评 enum
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2019/11/5
 */
public enum TrialEnum {

    /**
     * 不是试评
     */
    DEFAULT(0, "不是试评"),
    /**
     * 初始化试评数据
     */
    INIT(1, "初始化试评数据"),
    /**
     * 开始试评
     */
    START_TRIAL(2, "开始试评"),
    /**
     * 正式任务
     */
    START_FORMAL(3, "正式任务");

    private int id;

    private String name;

    private TrialEnum(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    /**
     * 状态转换 toId
     *
     * @param value
     * @return
     */
    public static int convertToId(String value) {
        if (Objects.equals(value.trim(), DEFAULT.name)) {
            return DEFAULT.getId();
        } else if (Objects.equals(value.trim(), INIT.name)) {
            return INIT.getId();
        } else if (Objects.equals(value.trim(), START_FORMAL.name)) {
            return START_FORMAL.getId();
        } else {
            return START_TRIAL.getId();
        }
    }

    /**
     * 状态转换 toName
     *
     * @param id
     * @return
     */
    public static String convertToName(int id) {
        if (id == DEFAULT.getId()) {
            return DEFAULT.name;
        } else if (id == INIT.getId()) {
            return INIT.name;
        } else if (id == START_FORMAL.getId()) {
            return START_FORMAL.name;
        } else {
            return START_TRIAL.name;
        }
    }
}
