package com.goafanti.common.enums;

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

import org.apache.commons.lang3.StringUtils;

public enum UserLockReleaseStatus {
	LOCKED(0,"锁定中"),
	WAIT_RELEASE(1,"待释放"),
	RELEASE(2,"已释放"),
	OTHER(10, "其他");
	
	private Integer	code;
	private String	desc;

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

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

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

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

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

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

	public Integer getCode() {
		return code;
	}

	public String getDesc() {
		return desc;
	}
}
