PageRenderTime 29ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/protocols/jain-megaco/megaco-api/src/main/java/javax/megaco/association/TransportType.java

http://mobicents.googlecode.com/
Java | 91 lines | 72 code | 19 blank | 0 comment | 2 complexity | a92d266640ea993c0bf57c2b3a0257a9 MD5 | raw file
Possible License(s): LGPL-3.0, GPL-3.0, LGPL-2.1, GPL-2.0, CC-BY-SA-3.0, CC0-1.0, Apache-2.0, BSD-3-Clause
  1. package javax.megaco.association;
  2. import java.io.Serializable;
  3. public class TransportType implements Serializable {
  4. public static final int M_TCP_TPT = 1;
  5. public static final int M_UDP_TPT = 2;
  6. public static final int M_SCTP_TPT = 3;
  7. public static final int M_ATM_TPT = 4;
  8. public static final int M_MTP3B_TPT = 5;
  9. public static final TransportType TCP_TPT = new TransportType(M_TCP_TPT);
  10. public static final TransportType UDP_TPT = new TransportType(M_UDP_TPT);
  11. public static final TransportType SCTP_TPT = new TransportType(M_SCTP_TPT);
  12. public static final TransportType ATM_TPT = new TransportType(M_ATM_TPT);
  13. public static final TransportType MTP3B_TPT = new TransportType(M_MTP3B_TPT);
  14. private int transport_type;
  15. private TransportType(int transport_type) {
  16. this.transport_type = transport_type;
  17. }
  18. public int getTransportType() {
  19. return this.transport_type;
  20. }
  21. public static final TransportType getObject(int value) throws IllegalArgumentException {
  22. TransportType t = null;
  23. switch (value) {
  24. case M_TCP_TPT:
  25. t = TCP_TPT;
  26. break;
  27. case M_UDP_TPT:
  28. t = UDP_TPT;
  29. break;
  30. case M_SCTP_TPT:
  31. t = SCTP_TPT;
  32. break;
  33. case M_ATM_TPT:
  34. t = ATM_TPT;
  35. break;
  36. case M_MTP3B_TPT:
  37. t = MTP3B_TPT;
  38. break;
  39. default:
  40. IllegalArgumentException illegalArgumentException = new IllegalArgumentException("No TransportType defined for value = " + value);
  41. throw illegalArgumentException;
  42. }
  43. return t;
  44. }
  45. private Object readResolve() {
  46. return this.getObject(this.transport_type);
  47. }
  48. @Override
  49. public String toString() {
  50. String t = null;
  51. switch (this.transport_type) {
  52. case M_TCP_TPT:
  53. t = "TransportType[TCP_TPT]";
  54. break;
  55. case M_UDP_TPT:
  56. t = "TransportType[UDP_TPT]";
  57. break;
  58. case M_SCTP_TPT:
  59. t = "TransportType[SCTP_TPT]";
  60. break;
  61. case M_ATM_TPT:
  62. t = "TransportType[ATM_TPT]";
  63. break;
  64. case M_MTP3B_TPT:
  65. t = "TransportType[MTP3B_TPT]";
  66. break;
  67. default:
  68. t = "TransportType[" + this.transport_type + "]";
  69. }
  70. return t;
  71. }
  72. }