package com.sifang.modules.factory.aiswei.util;

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

/**
 * 爱士惟省码对应关系
 */
public enum AisweiProvinceCode {

    Anhui("安徽省","1"),
    Beijing("北京市","2"),
    Chongqing("重庆市","3"),
    Fujian("福建省","4"),
    Gansu("甘肃省","5"),
    Guangdong("广东省","6"),
    Guangxi("广西壮族自治区","7"),
    Guizhou("贵州省","8"),
    Hainan("海南省","9"),
    Hebei("河北省","10"),
    Heilongjiang("黑龙江省","11"),
    Henan("河南省","12"),
    HongKong("香港特别行政区","13"),
    Hubei("湖北省","14"),
    Hunan("湖南省","15"),
    Jiangsu("江苏省","16"),
    Jiangxi("江西省","17"),
    Jilin("吉林省","18"),
    Liaoning("辽宁省","19"),
    Macau("澳门特别行政区","20"),
    InnerMongolia("内蒙古自治区","21"),
    Ningxia("宁夏回族自治区","22"),
    Qinghai("青海省","23"),
    Shandong("山东省","24"),
    Shanxi("山西省","25"),
    Shanxi2("陕西省","26"),
    Shanghai("上海市","27"),
    Sichuan("四川省","28"),
    Taiwan("台湾","29"),
    Tianjin("天津市","30"),
    Tibet("西藏自治区","31"),
    Sinkiang("新疆维吾尔自治区","32"),
    Yunnan("云南省","33"),
    Zhejiang("浙江省","34");

    private String name;//状态名称
    private String provinceCode;//内部编码

    public String getName() {
        return name;
    }

    public String getProvinceCode() {
        return provinceCode;
    }

    private AisweiProvinceCode(String name, String provinceCode){
        this.name = name;
        this.provinceCode = provinceCode;
    }

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