java枚举类的用法

public enum TaggingStatusEnum {

    NO_TAGGING(0,"未标注"),
    HAVE_TAGGING(1,"已标注"),
    TO_MAKE_SURE(2,"待确认"),
    ;
    private Integer code;

    private String name;

    TaggingStatusEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static Integer getEnumCode(String name){
        for(TaggingStatusEnum statusEnum :TaggingStatusEnum.values()){
            if(statusEnum.getName().equals(name)){
                return statusEnum.getCode();
            }
        }
        return null;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }
}

你可能感兴趣的:(java,开发语言)