package jnpf.enums.cultivate.task;

import lombok.Getter;

import java.util.Objects;

/**
 * 任务阶段项状态枚举 (-1-未配置 0-未完成 1-已完成)
 */
@Getter
public enum TaskStateEnum {
    NOT_CONFIGURED(-1, "未配置"),
    INCOMPLETE(0, "未完成"),
    COMPLETED(1, "已完成");

    final Integer code;
    final String msg;

    TaskStateEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static String getMsg(Integer code) {
        TaskStateEnum[] values = TaskStateEnum.values();
        for (TaskStateEnum value : values) {
            if (Objects.equals(value.getCode(), code)) {
                return value.getMsg();
            }
        }
        return null;
    }

    public static TaskStateEnum getEnum(Integer code) {
        TaskStateEnum[] values = TaskStateEnum.values();
        for (TaskStateEnum value : values) {
            if (Objects.equals(value.getCode(), code)) {
                return value;
            }
        }
        return null;
    }
}