package com.bcxin.ins.third.xyx.yb_enum;

/**
 * <b> 邮编枚举，省级 </b>
 * @author ZXF
 * @create 2018/02/27 0027 16:06
 * @version
 * @注意事项 </b>
 */
public enum YB_Province {

    HN {public String getValue(){return "0";} public String getName(){return "河南";}},
    XJ {public String getValue(){return "1";} public String getName(){return "新疆";}},
    LN {public String getValue(){return "2";} public String getName(){return "辽宁";}},
    GX {public String getValue(){return "3";} public String getName(){return "广西";}},
    SD {public String getValue(){return "4";} public String getName(){return "山东";}},
    HAIN {public String getValue(){return "5";} public String getName(){return "海南";}},
    FJ {public String getValue(){return "6";} public String getName(){return "福建";}},
    JL {public String getValue(){return "7";} public String getName(){return "吉林";}},
    HUB {public String getValue(){return "8";} public String getName(){return "湖北";}},
    TJ {public String getValue(){return "9";} public String getName(){return "天津";}},
    SX {public String getValue(){return "10";} public String getName(){return "山西";}},
    HB {public String getValue(){return "11";} public String getName(){return "河北";}},
    SH {public String getValue(){return "12";} public String getName(){return "上海";}},
    QH {public String getValue(){return "13";} public String getName(){return "青海";}},
    JS {public String getValue(){return "14";} public String getName(){return "江苏";}},
    JX {public String getValue(){return "15";} public String getName(){return "江西";}},
    GS {public String getValue(){return "16";} public String getName(){return "甘肃";}},
    YN {public String getValue(){return "17";} public String getName(){return "云南";}},
    IM {public String getValue(){return "18";} public String getName(){return "内蒙古";}},
    AH {public String getValue(){return "19";} public String getName(){return "安徽";}},
    ZJ {public String getValue(){return "20";} public String getName(){return "浙江";}},
    HLJ {public String getValue(){return "21";} public String getName(){return "黑龙江";}},
    GZ {public String getValue(){return "22";} public String getName(){return "贵州";}},
    GD {public String getValue(){return "23";} public String getName(){return "广东";}},
    HUN {public String getValue(){return "24";} public String getName(){return "湖南";}},
    CQ {public String getValue(){return "25";} public String getName(){return "重庆";}},
    SC {public String getValue(){return "26";} public String getName(){return "四川";}},
    BJ {public String getValue(){return "27";} public String getName(){return "北京";}},
    NX {public String getValue(){return "28";} public String getName(){return "宁夏";}},
    TB {public String getValue(){return "29";} public String getName(){return "西藏";}},
    SHX {public String getValue(){return "30";} public String getName(){return "陕西";}};

    public abstract String getValue();

    public abstract String getName();

    /**
     * 根据类型的名称，返回类型的枚举实例。
     *
     * @param code 类型
     */
    public static YB_Province fromYBProvince(String code) {
        String[] pro_code_arr = {"HN","XJ","LN","GX","SD","HAIN","FJ","JL","HUB","TJ","SX","HB","SH","QH","JS","JX","GS","YN","IM","AH","ZJ","HLJ","GZ","GD","HUN","CQ","SC","BJ","NX","TB","SHX"};
        int count = 0;
        for(String pro_code : pro_code_arr){
            if(pro_code.equals(code)){
                for (YB_Province province : YB_Province.values()) {
                    if (province.getValue().equals(String.valueOf(count))) {
                        return province;
                    }
                }
            }
            count ++;
        }
        return null;
    }

    public static void main(String[] args){
        String a = "HN#河南;XJ#新疆;LN#辽宁;GX#广西;SD#山东;HAIN#海南;FJ#福建;JL#吉林;HUB#湖北;TJ#天津;SX#山西;HB#河北;SH#上海;QH#青海;JS#江苏;JX#江西;GS#甘肃;YN#云南;IM#内蒙古;AH#安徽;ZJ#浙江;HLJ#黑龙江;GZ#贵州;GD#广东;HUN#湖南;CQ#重庆;SC#四川;BJ#北京;NX#宁夏;TB#西藏;SHX#陕西";
        String[] ar = a.split(";");
        int count = 0;
        String c = "{";
        String d = ",";
        for(String b : ar){
            String[] br = b.split("#");
            if(ar.length == (count+1)){
                d = "";
            }
            c = c + "\""+br[0]+"\""+d;
            count++;
        }
        c = c + "}";
        System.out.println(c);
    }
}
