package com.goafanti.common.enums;

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

import org.apache.commons.lang3.StringUtils;

public enum DeleteStatus {
	
	UNDELETE(0, "未删除"),
	DELETED(1, "已删除"),
	LOCKING(2,"已锁定"),
	OTHER(6, "其他");

	private DeleteStatus(Integer code, String desc) {
		this.code = code;
		this.desc = desc;
	}

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

	static {
		for (DeleteStatus value : DeleteStatus.values()) {
			status.put(value.getCode(), value);
		}
	}

	public static DeleteStatus getStatus(Integer code) {
		if (containsType(code)) {
			return status.get(code);
		}
		return OTHER;
	}

	public static DeleteStatus getStatus(String code) {
		if (StringUtils.isNumeric(code)) {
			return getStatus(Integer.parseInt(code));
		}
		return OTHER;
	}

	public static boolean containsType(Integer code) {
		return status.containsKey(code);
	}

	private Integer	code;
	private String	desc;

	public Integer getCode() {
		return code;
	}

	public String getDesc() {
		return desc;
	}

}
