package com.copy.trade.enums;

import lombok.Getter;

import java.util.Arrays;

@Getter
public enum EntrustTypeEnum{
	MARKET_PRICE(0,"MARKET_PRICE","市价"),
    LIMIT_PRICE(1,"LIMIT_PRICE","限价"),
    TRIGGER(2,"TRIGGER","计划委托"),
    ;
    private Integer type;
    private String typeStr;
    private String des;

    EntrustTypeEnum(Integer type, String typeStr, String des) {
        this.type = type;
        this.typeStr = typeStr;
        this.des = des;
    }
    public static EntrustTypeEnum getByType(Integer type){
        return  Arrays.asList(values()).stream()
                .filter(entrustTypeEnum -> entrustTypeEnum.getType().equals(type))
                .findFirst().orElse(null);
    }

    public static EntrustTypeEnum getByTypeStr(String typeStr){
        return  Arrays.asList(values()).stream()
                .filter(entrustTypeEnum -> entrustTypeEnum.getTypeStr().equals(typeStr))
                .findFirst().orElse(null);
    }
}