package com.goafanti.news.enums;

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


public enum NewsFields {
	
	ID("id", "科技讲堂ID"),
	TITLE("title", "标题"),
	TITLEIMG("titleImg", "题图url"),
	AUTHOR("author", "作者"),
	TYPE("type", "类型"),
	HOT("hot", "大咖说页面展示标记"),
	SOURCE("source", "来源"),
	SOURCEURL("sourceUrl", "来源url"),
	SUMMARY("summary", "简介"),
	CONTENT("content", "内容"),
	OTHER("", "未知参数");
	
	private String	code;
	private String	desc;
	
	private static Map<String, NewsFields> status = new HashMap<String, NewsFields>();
	
	private NewsFields(String code, String desc) {
		this.code = code;
		this.desc = desc;
	}
	
	static {
		for (NewsFields value : NewsFields.values()) {
			status.put(value.getCode(), value);
		}
	}
	
	public static NewsFields getField(String code) {
		if (containsType(code)) {
			return status.get(code);
		}
		return OTHER;
	}
	
	public static String getFieldDesc(String code) {
		return getField(code).getDesc();
	}

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

	public String getDesc() {
		return desc;
	}

}
