package com.tzy.common.enums;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

@Getter
public enum DiallingCodeEnums {
    //"86" "852"  "853"  "886"
    CHINA("+86","中国"),
    HONGKONG("+852","中国香港"),
    MACAO("+853","中国澳门"),
    TAIWAN("+886","中国台湾"),
    UNKNOWN("UNKNOWN","未知")
    ;

    private String code;
    private String msg;

    DiallingCodeEnums(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static boolean checkEquals(String fromCode, DiallingCodeEnums toCode){
        if(StringUtils.isBlank(fromCode)){
            return false;
        }
        if(!StringUtils.trim(fromCode).startsWith("+")){
            fromCode = "+" + StringUtils.trim(fromCode);
        }
        return Objects.equals(fromCode, toCode.getCode());
    }

}
