/protocols/jain-megaco/megaco-api/src/main/java/javax/megaco/message/CmdRequestType.java

http://mobicents.googlecode.com/ · Java · 124 lines · 96 code · 28 blank · 0 comment · 2 complexity · 9fb1cdcaef0670f9133ac69e0770debe MD5 · raw file

  1. package javax.megaco.message;
  2. import java.io.Serializable;
  3. public class CmdRequestType implements Serializable {
  4. public static final int M_ADD_REQ = 1;
  5. public static final int M_MODIFY_REQ = 2;
  6. public static final int M_MOVE_REQ = 3;
  7. public static final int M_SERVICE_CHANGE_REQ = 4;
  8. public static final int M_NOTIFY_REQ = 5;
  9. public static final int M_AUDIT_VAL_REQ = 6;
  10. public static final int M_AUDIT_CAP_REQ = 7;
  11. public static final int M_SUBTRACT_REQ = 8;
  12. public static final CmdRequestType ADD_REQ = new CmdRequestType(M_ADD_REQ);
  13. public static final CmdRequestType MODIFY_REQ = new CmdRequestType(M_MODIFY_REQ);
  14. public static final CmdRequestType MOVE_REQ = new CmdRequestType(M_MOVE_REQ);
  15. public static final CmdRequestType SERVICE_CHANGE_REQ = new CmdRequestType(M_SERVICE_CHANGE_REQ);
  16. public static final CmdRequestType NOTIFY_REQ = new CmdRequestType(M_NOTIFY_REQ);
  17. public static final CmdRequestType AUDIT_VAL_REQ = new CmdRequestType(M_AUDIT_VAL_REQ);
  18. public static final CmdRequestType AUDIT_CAP_REQ = new CmdRequestType(M_AUDIT_CAP_REQ);
  19. public static final CmdRequestType SUBTRACT_REQ = new CmdRequestType(M_SUBTRACT_REQ);
  20. private int cmd_type;
  21. private CmdRequestType(int cmd_type) {
  22. this.cmd_type = cmd_type;
  23. }
  24. public int getCmdRequestType() {
  25. return this.cmd_type;
  26. }
  27. public static final CmdRequestType getObject(int value) throws IllegalArgumentException {
  28. CmdRequestType c = null;
  29. switch (value) {
  30. case M_ADD_REQ:
  31. c = ADD_REQ;
  32. break;
  33. case M_MODIFY_REQ:
  34. c = MODIFY_REQ;
  35. break;
  36. case M_MOVE_REQ:
  37. c = MOVE_REQ;
  38. break;
  39. case M_SERVICE_CHANGE_REQ:
  40. c = SERVICE_CHANGE_REQ;
  41. break;
  42. case M_NOTIFY_REQ:
  43. c = NOTIFY_REQ;
  44. break;
  45. case M_AUDIT_VAL_REQ:
  46. c = AUDIT_VAL_REQ;
  47. break;
  48. case M_AUDIT_CAP_REQ:
  49. c = AUDIT_CAP_REQ;
  50. break;
  51. case M_SUBTRACT_REQ:
  52. c = SUBTRACT_REQ;
  53. break;
  54. default:
  55. IllegalArgumentException illegalArgumentException = new IllegalArgumentException("No CmdRequestType defined for value = " + value);
  56. throw illegalArgumentException;
  57. }
  58. return c;
  59. }
  60. private Object readResolve() {
  61. return this.getObject(this.cmd_type);
  62. }
  63. @Override
  64. public String toString() {
  65. String c = null;
  66. switch (this.cmd_type) {
  67. case M_ADD_REQ:
  68. c = "CmdType[ADD_REQ]";
  69. break;
  70. case M_MODIFY_REQ:
  71. c = "CmdType[MODIFY_REQ]";
  72. break;
  73. case M_MOVE_REQ:
  74. c = "CmdType[MOVE_REQ]";
  75. break;
  76. case M_SERVICE_CHANGE_REQ:
  77. c = "CmdType[SERVICE_CHANGE_REQ]";
  78. break;
  79. case M_NOTIFY_REQ:
  80. c = "CmdType[NOTIFY_REQ]";
  81. break;
  82. case M_AUDIT_VAL_REQ:
  83. c = "CmdType[AUDIT_VAL_REQ]";
  84. break;
  85. case M_AUDIT_CAP_REQ:
  86. c = "CmdType[AUDIT_CAP_REQ]";
  87. break;
  88. case M_SUBTRACT_REQ:
  89. c = "CmdType[SUBTRACT_REQ]";
  90. break;
  91. default:
  92. c = "CmdType[" + this.cmd_type + "]";
  93. }
  94. return c;
  95. }
  96. }