package com.simuwang.base.common.enums;

import java.util.stream.Stream;

/**
 * FileName: DistributeType
 * Author:   chenjianhua
 * Date:     2024/9/16 13:30
 * Description: ${DESCRIPTION}
 */
public enum DistributeType {
    //单位分红/拆分比例
    CASH_DIVIDENDS(1, "分红"), DIVIDENDS_SPLIT(2, "拆分");

    private final Integer code;
    private final String info;

    DistributeType(Integer code, String info) {
        this.code = code;
        this.info = info;
    }

    public static DistributeType getDistributeTypeByCode(Integer code) {
        if (null == code){
            return null;
        }
        for(DistributeType s : DistributeType.values()){
            if(code.equals(s.getCode())){
                return s;
            }
        }
        return null;
    }

    public static DistributeType getDistributeTypeByInfo(String info) {
        return Stream.of(DistributeType.values()).filter(e -> e.info.equals(info)).findFirst().orElse(null);
    }

    public Integer getCode() {
        return code;
    }

    public String getInfo() {
        return info;
    }
}
