package com.smppw.common.pojo;

import java.util.stream.Stream;

/**
 * 新 - 第一级策略
 */
public enum FundFuturesOption {

	/** 期货及其衍生品数据**/
	All(0, "全部","All"),
	Product(1, "商品","Product"),
	Bond(2, "国债","Bond"),
	StockIndex(3, "股指","StockIndex"),
	Future(4, "期权","Future"),
	Other(5, "其他衍生品","Other"),
	PreciousMetal(11, "贵金属","PreciousMetal"),
	Metal(12, "金属","Metal"),
	NonFerrousMetal(13, "有色","NonFerrousMetal"),
	BlackMetal(17, "黑色","BlackMetal"),
	Energization(14, "能化","Energization"),
	IndustrialProducts(15, "工业品","IndustrialProducts"),
	AgriculturalProducts(16, "农产品","AgriculturalProducts"),
	StockIndexFuture(31, "股指期货","StockIndexFuture"),
	StockIndexOption(41, "股指期权","StockIndexOption"),
	BondFuture(21, "国债期货","BondFuture");
	private Integer id;
	private String nameDesc;
	private String nameEnDesc;

	FundFuturesOption(int id, String nameDesc, String nameEnDesc) {
		this.id = id;
		this.nameDesc = nameDesc;
		this.nameEnDesc = nameEnDesc;
	}

	public int getId() {
		return id;
	}

	public String getNameDesc() {
		return nameDesc;
	}
	public String getNameEnDesc() {
		return nameEnDesc;
	}


	public static FundFuturesOption getFundFuturesOption(Integer id) {
		return Stream.of(FundFuturesOption.values()).filter(e -> e.id.equals(id)).findFirst().orElse(null);
	}

	public static FundFuturesOption getFundFuturesOption(String id) {
		if (null == id){
			return null;
		}
		for(FundFuturesOption s : FundFuturesOption.values()){
			if(id.equals(s.getId()+"") || id.equals(s.name())){
				return s;
			}
		}
		return null;
	}

	public static FundFuturesOption getFundFuturesOptionByName(String name) {
		if (null == name){
			return null;
		}
		for(FundFuturesOption s : FundFuturesOption.values()){
			if(name.equals(s.getNameDesc()+"")){
				return s;
			}
		}
		return null;
	}
	public static FundFuturesOption getFundFuturesOptionByEnName(String name) {
		if (null == name){
			return null;
		}
		for(FundFuturesOption s : FundFuturesOption.values()){
			if(name.equals(s.getNameEnDesc()+"")){
				return s;
			}
		}
		return null;
	}
}
