简单的enum转map

package com.ejlerp.baseinfo.manager.enums;

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

/**
 * 对尺码做排序
**/

public enum SkuSizeSortEnum {

    CM_LOWER("cm", 0),
    CM_UPPER("CM", 0),
    S_LOWER("s", 1),
    S_UPPER("S", 1),
    M_LOWER("m", 2),
    M_UPPER("M", 2),
    L_LOWER("l", 3),
    L_UPPER("L", 3),
    XL_LOWER("xl", 4),
    XL_UPPER("XL", 4),
    XXL_LOWER("xxl", 5),
    XXL_UPPER("XXL", 5),
    XXL_LOWER_FIGURE("2xl", 5),
    XXL_UPPER_FIGURE("2XL", 5),
    XXXL_LOWER("xxxl", 6),
    XXXL_UPPER("XXXL", 6),
    XXXL_LOWER_FIGURE("3xl", 6),
    XXXL_UPPER_FIGURE("3XL", 6);

    private String sizeName;
    private Integer sort;

    SkuSizeSortEnum(String sizeName, Integer sort) {
        this.sizeName = sizeName;
        this.sort = sort;
    }

    public String getSizeName() {
        return sizeName;
    }

    public void setSizeName(String sizeName) {
        this.sizeName = sizeName;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public static Map<String, Integer> typeMap = new HashMap<>();
    static {
        SkuSizeSortEnum[] types = SkuSizeSortEnum.values();
        for (SkuSizeSortEnum type : types) {
            typeMap.put(type.sizeName, type.sort);
        }
    }
}

你可能感兴趣的:(java,jvm,servlet)