package com.goafanti.techproject.enums;

import java.util.HashMap;
import java.util.Map;



public enum TaskState {
	/** 未分配 **/
	UN_DISTRIBUTION(0,"未分配"),
	/** 已分配 **/
	DISTRIBUTION(1,"已分配"),
	/** 材料已启动 **/
	STARTED(2,"材料已启动"),
	/** 材料已完成 **/
	COMPLETE(3,"材料已完成"),
	/** **/
	INVALID(10,"未定义");
	private TaskState(Integer code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	private static Map<Integer, TaskState> status = new HashMap<Integer, TaskState>();

	static {
		for (TaskState value : TaskState.values()) {
			status.put(value.getCode(), value);
		}
	}
	public static TaskState getStatus(Integer code) {
		if (containsType(code)) {
			return status.get(code);
		}
		return INVALID;
	}
	public static String getValueByCode(Integer code){
        for(TaskState taskState:TaskState.values()){
            if(code.equals(taskState.getCode())){
                return taskState.getDesc();
            }
        }
        return  null;
    }
	public static boolean containsType(Integer code) {
		return status.containsKey(code);
	}
	private Integer	code;
	private String	desc;
	public Integer getCode() {
		return code;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public String getDesc() {
		return desc;
	}
	public void setDesc(String desc) {
		this.desc = desc;
	}
	
}
