package me.xhh.utils; /** * Status definition for operations. */ public enum Status { // common cases /** operation succeeded */ Success(0), /** operation failed */ Error(-1), // other cases _1(1), _2(2), _3(3), _4(4), _5(5), _6(6), _7(7); private int code; private Status(int code) { this.code = code; } /** * The code, e.g. "0" for <code>Success</code>, "-1" for <code>Error</code>, "1" for <code>_1</code>. */ @Override public String toString() { return Integer.toString(code); } public boolean isSuccess() { return this == Success; } public boolean notSuccess() { return this != Success; } public boolean is_1() { return this == _1; } public boolean is_2() { return this == _2; } public boolean is_3() { return this == _3; } public boolean is_4() { return this == _4; } public boolean is_5() { return this == _5; } public boolean is_6() { return this == _6; } public boolean is_7() { return this == _7; } }