package com.simuwang.base.common.enums;

import java.util.stream.Stream;

/**
 * FileName: DeletionType
 * Author:   chenjianhua
 * Date:     2024/9/17 22:10
 * Description: ${DESCRIPTION}
 */
public enum DeletionType {
    //单位分红/拆分比例
    NAV_DELETION(1, "净值缺失"), ASSET_DELETION(2, "规模缺失"),
    DISTRIBUTION_DELETION(3, "分红缺失"), NO_DELETION(4, "已补充"),EXIST_SPLIT(4, "存在拆分");

    private final Integer code;
    private final String info;

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

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

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

    public Integer getCode() {
        return code;
    }

    public String getInfo() {
        return info;
    }
}
