package com.sifang.modules.factory;


import java.util.Optional;
import java.util.stream.Stream;

public enum BrandFactInfo {

    Jinlang("锦浪", "锦浪云","01", false),
    GoodW("固德威","固德威","02", true),
    Aiswei("爱士惟","爱士惟","03", true);

    private String brandName;//品牌名称
    private String factoryName;//厂家平台
    private String brandType;//品牌对应类型id
    private boolean yzCodeFlag;//是否需要验证码

    public String getBrandName() {
        return brandName;
    }

    public String getFactoryName() {
        return factoryName;
    }

    public String getBrandType() {
        return brandType;
    }

    public boolean isYzCodeFlag() {
        return yzCodeFlag;
    }

    BrandFactInfo(String brandName,String factoryName, String brandType, boolean yzCodeFlag) {
        this.brandName = brandName;
        this.factoryName = factoryName;
        this.brandType = brandType;
        this.yzCodeFlag = yzCodeFlag;
    }

    public static BrandFactInfo externalOf(String brandName){
        return Optional.ofNullable(brandName)
                .map(v -> Stream.of(values()).filter(s -> s.brandName.equals(v)).findFirst().orElse(null))
                .orElse(null);
    }

    public static BrandFactInfo matchType(String brandType){
        return Optional.ofNullable(brandType)
                .map(v -> Stream.of(values())
                        .filter(s -> s.brandType.equals(v))
                        .findFirst()
                        .orElse(null))
                .orElse(null);
    }
}
