package com.goafanti.common.enums;

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

import org.apache.commons.lang3.StringUtils;

public enum CopyrightStatus {
	CREATE(0, "创建"),
	SIGN(1, "签单"),
	DELIVERD(2, "派单"),
	CIRCULATION(3, "流转"),
	SUBMIT(4, "材料提交"),
	ACCEPT(5, "受理"),
	AMEND(6, "补正"),
	REJECT(7, "驳回"),
	AUTHORIZED(8, "已下证"),
	SETTLEMENT(9, "已结款"),
	CALLBACK(10, "退单"),
	OTHER(11, "其他");

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

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

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

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

	public static CopyrightStatus 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;
	}
}
