package com.rongwei.bsentity.enums;

import lombok.Getter;

import java.util.Arrays;
import java.util.stream.Stream;

/**
 * @author shangmi
 * @title PlantEnum
 * @date 2023/12/8 16:26
 * @description 工厂枚举
 */
@Getter
public enum PlantEnum {
    CXLB("0001651000000015EFDD","山东创新箔材科技有限公司","CXLB"),
    CXJL("0001651000000017DRZ1","山东创新精铝金属制造有限公司","CXJL"),
    CXBC("0001S31000000000J0TR","山东创新板材有限公司","CXBC")
    ;
    private final String id;
    private final String name;
    private final String addr;

    PlantEnum(String id, String name,String addr) {
        this.id = id;
        this.name = name;
        this.addr = addr;
    }

    public static String idOf(String name){
        return getPlantById(name,null).id;
    }

    public static PlantEnum getPlantById(String name,PlantEnum plantEnum){
        return Stream.of(values()).filter(info -> name.equals(info.name)).findFirst().orElse(plantEnum);
    }

    public static String nameOf(String id){
        return getPlantByName(id,null).name;
    }

    public static PlantEnum getPlantByName(String id,PlantEnum plantEnum){
        return Stream.of(values()).filter(info -> id.equals(info.id)).findFirst().orElse(plantEnum);
    }

    public static String addrOf(String id){
        return getPlantByName(id,null).addr;
    }

    public static PlantEnum getPlantByaddr(String id,PlantEnum plantEnum){
        return Stream.of(values()).filter(info -> id.equals(info.id)).findFirst().orElse(plantEnum);
    }
}
