package com.smppw.common.pojo.enums;


import com.smppw.common.pojo.enums.strategy.Strategy;

/**
 * @author zhengsongliang
 */
public enum RaiseType {
	Private(1), Public(2), Both(3), Comb(4);//组合
	private int id;

	private RaiseType(int id) {
		this.id = id;
	}

	public int getId() {
		return id;
	}

	public static RaiseType getRaiseType(int id) {
		//		return Stream.of(RaiseType.values()).filter(e -> e.id == id).findFirst().orElse(null);
		if (Private.id == id)
			return Private;
		if (Public.id == id)
			return Public;
		if (Both.id == id)
			return Both;
		return null;
	}
	
	public static RaiseType getRaiseType(String id) {
		if (null == id)
			return null;
		// Private(1), Public(2), Both(3);
		if ("1".equals(id))
			return Private;
		if ("2".endsWith(id))
			return Public;
		if ("3".equals(id))
			return Both;
		return null;
	}

	public static RaiseType getRaiseType(CurveType curveType, Strategy strategy) {
		if (strategy == Strategy.All) {
			if (curveType == CurveType.PrivateComprehension)
				return Private;
			if (curveType == CurveType.PublicComprehension)
				return Public;
			
			return Both;
		}

		if (strategy == Strategy.Rights) {
			if (curveType == CurveType.PrivateRights)
				return Private;
			if (curveType == CurveType.PublicRights)
				return Public;

			return Both;
		} else {
			if (curveType == CurveType.PrivateSubstratgy)
				return Private;

			if (curveType == CurveType.PublicSubstrategy)
				return Public;

			return Both;
		}
	}

	public static RaiseType getRaiseType(int curveTypeId, int strategyId) {
		CurveType curveType = CurveType.getCurveType(curveTypeId);
		Strategy strategy = Strategy.getStrategy(strategyId);
		return getRaiseType(curveType, strategy);
	}
}
