/protocols/jain-megaco/megaco-api/src/main/java/javax/megaco/pkg/ParamRelation.java

http://mobicents.googlecode.com/ · Java · 108 lines · 85 code · 23 blank · 0 comment · 2 complexity · 4f2f59394eeb13e930565d49f3474b74 MD5 · raw file

  1. package javax.megaco.pkg;
  2. import java.io.Serializable;
  3. public class ParamRelation implements Serializable {
  4. private int relation_type;
  5. public static final int M_SET = 1;
  6. public static final int M_SUBLIST = 2;
  7. public static final int M_RANGE = 3;
  8. public static final int M_EQUAL = 4;
  9. public static final int M_NOT_EQUAL = 5;
  10. public static final int M_GREATER = 6;
  11. public static final int M_LESS = 7;
  12. public static final ParamRelation SET = new ParamRelation(M_SET);
  13. public static final ParamRelation SUBLIST = new ParamRelation(M_SUBLIST);
  14. public static final ParamRelation RANGE = new ParamRelation(M_RANGE);
  15. public static final ParamRelation EQUAL = new ParamRelation(M_EQUAL);
  16. public static final ParamRelation NOT_EQUAL = new ParamRelation(M_NOT_EQUAL);
  17. public static final ParamRelation GREATER = new ParamRelation(M_GREATER);
  18. public static final ParamRelation LESS = new ParamRelation(M_LESS);
  19. private ParamRelation(int relation_type) {
  20. this.relation_type = relation_type;
  21. }
  22. public int getParamRelation() {
  23. return this.relation_type;
  24. }
  25. public static final ParamRelation getObject(int value) throws IllegalArgumentException {
  26. ParamRelation p = null;
  27. switch (value) {
  28. case (M_SET):
  29. p = SET;
  30. break;
  31. case (M_SUBLIST):
  32. p = SUBLIST;
  33. break;
  34. case (M_RANGE):
  35. p = RANGE;
  36. break;
  37. case (M_EQUAL):
  38. p = EQUAL;
  39. break;
  40. case (M_NOT_EQUAL):
  41. p = NOT_EQUAL;
  42. break;
  43. case (M_GREATER):
  44. p = GREATER;
  45. break;
  46. case (M_LESS):
  47. p = LESS;
  48. default:
  49. throw new IllegalArgumentException("There is no ParamRelation for passed value = " + value);
  50. }
  51. return p;
  52. }
  53. private Object readResolve() {
  54. return this.getObject(this.relation_type);
  55. }
  56. @Override
  57. public String toString() {
  58. String p = null;
  59. switch (this.relation_type) {
  60. case (M_SET):
  61. p = "ParamRelation[SET]";
  62. break;
  63. case (M_SUBLIST):
  64. p = "ParamRelation[SUBLIST]";
  65. break;
  66. case (M_RANGE):
  67. p = "ParamRelation[RANGE]";
  68. break;
  69. case (M_EQUAL):
  70. p = "ParamRelation[EQUAL]";
  71. break;
  72. case (M_NOT_EQUAL):
  73. p = "ParamRelation[NOT_EQUAL]";
  74. break;
  75. case (M_GREATER):
  76. p = "ParamRelation[GREATER]";
  77. break;
  78. case (M_LESS):
  79. p = "ParamRelation[LESS]";
  80. default:
  81. p = "ParamRelation[" + this.relation_type + "]";
  82. }
  83. return p;
  84. }
  85. }