com.dodopal.common.enums.IdentityTypeEnum.java Source code

Java tutorial

Introduction

Here is the source code for com.dodopal.common.enums.IdentityTypeEnum.java

Source

package com.dodopal.common.enums;

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

import org.apache.commons.lang.StringUtils;

/**
 *  ?
 * @author lifeng
 */

public enum IdentityTypeEnum {
    ID_CARD("0", "?"), DRIVING_LICENSE("1", ""), PASSPORT("2", "");

    private static final Map<String, IdentityTypeEnum> map = new HashMap<String, IdentityTypeEnum>(values().length);

    static {
        for (IdentityTypeEnum identityType : values()) {
            map.put(identityType.getCode(), identityType);
        }
    }

    private String code;
    private String name;

    private IdentityTypeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static IdentityTypeEnum getIdentityTypeByCode(String code) {
        if (StringUtils.isBlank(code)) {
            return null;
        }
        return map.get(code);
    }
}