package com.yc.ship.module.trade.enums;

public enum CardTypeEnum {
    ID_CARD("0", "身份证","01"),
    PASS_PORT("1", "护照","03"),
    HONG_KONG_AND_MACAO_PASS("3", "港澳通行证","48"),
    ;

    private String id;

    private String desc;

    private String insuranceCardCode;

    CardTypeEnum(String id, String desc, String insuranceCardCode) {
        this.id = id;
        this.desc = desc;
        this.insuranceCardCode = insuranceCardCode;
    }

    public String Id() {
        return id;
    }

    public String Desc() {
        return desc;
    }

    public String InsuranceCardCode() { return insuranceCardCode ;}

    public static CardTypeEnum getNullableEnum(String id){
        CardTypeEnum[] items = CardTypeEnum.values();
        for (CardTypeEnum item : items) {
            if(item.Id().equals(id)){
                return item;
            }
        }
        return CardTypeEnum.ID_CARD;
    }

    public static boolean contain(String id){
        CardTypeEnum[] items = CardTypeEnum.values();
        for (CardTypeEnum item : items) {
            if(item.Id().equals(id)){
                return true;
            }
        }
        return false;
    }

    public static String getDescByCode(String id) {
        if (null == id) {
            return null;
        }
        CardTypeEnum[] elements = values();
        for (CardTypeEnum element : elements) {
            if (element.Id().equals(id)) {
                return element.Desc();
            }
        }
        return null;
    }

    public boolean equalsId(String id){
        return this.Id().equals(id);
    }

    public static String getInsuranceCardCodeById(String id) {
        if (null == id) {
            return null;
        }
        CardTypeEnum[] elements = values();
        for (CardTypeEnum element : elements) {
            if (element.Id().equals(id)) {
                return element.InsuranceCardCode();
            }
        }
        return CardTypeEnum.ID_CARD.InsuranceCardCode();
    }
}
