Java enum enum class

Source: Internet
Author: User
Tags gettext

Figure A code:

public enum Logmethodenum {
Webcscardvalid ("return value"),
Webcsverifypassword ("return value"),
Webcssavepassword ("return value"),
Webcssetpassword ("return value"),
Webcsquerytotalbalance ("return value"),
Webcsquerycarddetail ("return value"),
Webcsquerycompinfor ("return value"),
Webcsquerytotaldetail ("return value"),
Webcsqueryacardinforex ("return value"),
Webcsqueryacardinfor ("return value"),
Webcsquerycardinfor ("return value"),
Webcsquerycardaccount ("return value"),
WEBCSQUERYCARDINFOR_NP ("return value"),
Webcsquerycardno ("return value"),
Webcsquerycdbydate ("return value"),
Webcsquerytdbydate ("return value"),
Webcsquerybusireport ("return value"),
Webcsquerydistribute ("return value"),
Webcsdistotalbalance ("return value"),
Webcslostcard ("return value");

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);
}

}

Figure II Code:

public enum Logcodeanddescenum {
SUCCESS ("0000", "description"),
Unlawfl_newspaper ("0001", "description"),
Message_domain ("0002", "description");

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) {//is converted to a description according to the status code
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;
}
}

}

Article Source: https://www.cnblogs.com/0c7x4/, reproduced please mark the original

Java enum enum class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.