1. 程式人生 > >列舉轉map

列舉轉map

import java.util.HashMap;
import java.util.Map;


public enum PayType {
 


    ALIPAY("支付寶掃碼", 15),

    WEIXIN_PAY("微信掃碼", 16)


    PayType(String name, int value) {
        this.name = name;
        this.value = value;
    }

    public int value;
    public String name;


    public static Map<String, PayType> typeMap = new
HashMap<String, PayType>(); static { PayType[] types = PayType.values(); for (PayType type : types) { typeMap.put(String.valueOf(type.value), type); } } }