Enumeration notes

There constructor (the constructor has parameters) enumeration of the more common ways:

/ ** 
 * task state enumeration class 
 * SYJ the Created by ON 2017/4/27. 
 * / 
Public  enum TaskStatusEnum { 

    NotStart ( 0),     // not started 
    Doing (. 1),        // performed in 
    the Pause (2),        / / pause 
    completed (3),    // has completed the 
    Del (4),          // delete 
    CutShort (5);    // ended prematurely 

    Private  int value; 
  Here is the constructor function only engage in early, in order to engage in the corresponding enumeration values, specific principle not go into TaskStatusEnum (
int value) { the this .Value = value; }
  This is a getter method
public int the getValue () { return value; } / ** * returns the enumerated value according to the value corresponding to * @param value * @return * / public static TaskStatusEnum valueOf ( int value) { Switch (value) { Case 0: return NotStart; Case . 1: return Doing; Case 2: return the Pause; Case . 3: return the Completed; case 4: return Del; case 5: return CutShort; default: return null; } } }

As it is now with the company

public  enum CheckStandCode { 
    PAY_SUCESS ( "00", "treatment success"), // interface call success 
    PAY_FAIL ( "01", "treatment failure"), // interface call returns a failure interface call abnormal, network anomalies, illegal parameters, parameters little pass ... 
    PAY_WAIT ( "02", "waiting for user pay" ), 
    PAY_PROCESSING ( "03", "payment processing" ), 
    PAY_CLOSED ( "04", "Order Close"), // order closure 
    PAY_FINISHED ( "05", "end transaction" ), 
    PAY_CASH_REFUND ( "06", "cash refund success" ), 
    PAY_REFUND ( "07", "refunded" ), 
    PAY_CANCELED ( "08", "Revoked " ), 
    PAY_REVOKED ( " 09 "," revoked (credit card payment) " ), 


    Private  Final String code;

    private final String message;

    private CheckStandCode(String code, String message){
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    @Override
    public String toString() {
        return "异常提示:状态码【"+code+"】,错误信息【"+message+"】";
    }
}

Then in the other classes can call like this:

PAY_FAIL_ORDER_EXISTS is an enumeration defined above

payOrderRsp.setResultCode(PAY_FAIL_ORDER_EXISTS.getCode());

 

Guess you like

Origin www.cnblogs.com/cherishforchen/p/10935636.html