JAVA->Enum

  public enum CodeEnum {

    TODO("1", "待办"),

    DONE("2", "已办");

    private String code;

    private String value;

    private CodeEnum(String code, String value) {

      this.code = code;

      this.value =  value;

    }

    setter...

    getter...

    public static String getValueFromCode(String code) {

      if(StringUtils.isNotEmpty(code)) {

        for(CodeEnum codeEnum : CodeEnum.values()) {

          result = codeEnum.getValue();

           break;

        }

      }

      return result;

    }

  }

posted @ 2018-12-25 14:44  风云灬信任  阅读(96)  评论(0编辑  收藏  举报