java enum 枚举类

 图一代码:

public enum LogMethodEnum {
  WEBCSCARDVALID("返回值"),
  WEBCSVERIFYPASSWORD("返回值"),
  WEBCSSAVEPASSWORD("返回值"),
  WEBCSSETPASSWORD("返回值"),
  WEBCSQUERYTOTALBALANCE("返回值"),
  WEBCSQUERYCARDDETAIL("返回值"),
  WEBCSQUERYCOMPINFOR("返回值"),
  WEBCSQUERYTOTALDETAIL("返回值"),
  WEBCSQUERYACARDINFOREX("返回值"),
  WEBCSQUERYACARDINFOR("返回值"),
  WEBCSQUERYCARDINFOR("返回值"),
  WEBCSQUERYCARDACCOUNT("返回值"),
  WEBCSQUERYCARDINFOR_NP("返回值"),
  WEBCSQUERYCARDNO("返回值"),
  WEBCSQUERYCDBYDATE("返回值"),
  WEBCSQUERYTDBYDATE("返回值"),
  WEBCSQUERYBUSIREPORT("返回值"),
  WEBCSQUERYDISTRIBUTE("返回值"),
  WEBCSDISTOTALBALANCE("返回值"),
  WEBCSLOSTCARD("返回值");

  private String text;

  public String getText() {
    return text;
  }

  public LogMethodEnum(String text) {
    this.text = text;
  }

  public static void main(String[] args) {
    String str="WebCSCardValid";
    String returnStr = LogMethodEnum.valueOf(WebCSCardValid).getText();
    System.out.println(returnStr);
  }

}

 

 

 图二代码:

public enum LogCodeAndDescEnum {
  SUCCESS("0000","描述"),
  UNLAWFL_NEWSPAPER("0001","描述"),
  MESSAGE_DOMAIN("0002","描述");

  private String code;
  private String desc;

  public String getDesc() {
    return desc;
  }

  public String getCode() {
    return code;
  }

  WebServiceLogStatusEnum(String code,String desc) {
    this.desc = desc;
    this.code = code;
  }

  public static String codeGetDesc(int value) { // 根据状态码转成描述
    if (String.valueOf(value).equals("0098")) {
    return SYSTEM_FAILURE.desc;
    }
    if (String.valueOf(value).equals("0099")) {
    return SYSTEM_FAILURE_OTHER.desc;
    }
    switch (value) {
    case 0000:
      return SUCCESS.desc;
    case 0001:
      return UNLAWFL_NEWSPAPER.desc;
    case 0002:
      return MESSAGE_DOMAIN.desc;
    default:
      return null;
    }
  }

}

文章来源:https://www.cnblogs.com/0c7x4/,转载请标明原著

posted @ 2018-06-06 18:17  smallf  阅读(198)  评论(1编辑  收藏  举报