java 에서 enum 정의시 특정값으로 정의하는 방법.
public enum ApiResponseCode {
/**
* The request was successful.
*/
SUCCESS(1000),
/**
* The request was canceled.
*/
CANCEL(1001),
/**
* A network error occurred.
*/
NETWORK_ERROR(1002),
/**
* A server error occurred.
*/
SERVER_ERROR(1003),
/**
* An authentication agent error occurred.
*/
AUTHENTICATION_AGENT_ERROR(1004),
/**
* An internal error occurred.
*/
INTERNAL_ERROR(1007),
/**
* A Purchase error occurred.
*/
PURCHASE_ERROR(1008);
int value;
ApiResponseCode(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}
int로 사용시엔 ordinal() 이 아닌 getValue() 를 사용하면 된다.