/protocols/jain-megaco/megaco-api/src/main/java/javax/megaco/association/TransportType.java
Java | 91 lines | 72 code | 19 blank | 0 comment | 2 complexity | a92d266640ea993c0bf57c2b3a0257a9 MD5 | raw file
1package javax.megaco.association; 2 3import java.io.Serializable; 4 5public class TransportType implements Serializable { 6 public static final int M_TCP_TPT = 1; 7 public static final int M_UDP_TPT = 2; 8 public static final int M_SCTP_TPT = 3; 9 public static final int M_ATM_TPT = 4; 10 public static final int M_MTP3B_TPT = 5; 11 12 public static final TransportType TCP_TPT = new TransportType(M_TCP_TPT); 13 public static final TransportType UDP_TPT = new TransportType(M_UDP_TPT); 14 public static final TransportType SCTP_TPT = new TransportType(M_SCTP_TPT); 15 public static final TransportType ATM_TPT = new TransportType(M_ATM_TPT); 16 public static final TransportType MTP3B_TPT = new TransportType(M_MTP3B_TPT); 17 18 private int transport_type; 19 20 private TransportType(int transport_type) { 21 this.transport_type = transport_type; 22 } 23 24 public int getTransportType() { 25 return this.transport_type; 26 } 27 28 public static final TransportType getObject(int value) throws IllegalArgumentException { 29 TransportType t = null; 30 switch (value) { 31 case M_TCP_TPT: 32 t = TCP_TPT; 33 break; 34 35 case M_UDP_TPT: 36 t = UDP_TPT; 37 break; 38 39 case M_SCTP_TPT: 40 t = SCTP_TPT; 41 break; 42 43 case M_ATM_TPT: 44 t = ATM_TPT; 45 break; 46 47 case M_MTP3B_TPT: 48 t = MTP3B_TPT; 49 break; 50 default: 51 IllegalArgumentException illegalArgumentException = new IllegalArgumentException("No TransportType defined for value = " + value); 52 throw illegalArgumentException; 53 } 54 return t; 55 56 } 57 58 private Object readResolve() { 59 return this.getObject(this.transport_type); 60 } 61 62 @Override 63 public String toString() { 64 String t = null; 65 switch (this.transport_type) { 66 case M_TCP_TPT: 67 t = "TransportType[TCP_TPT]"; 68 break; 69 70 case M_UDP_TPT: 71 t = "TransportType[UDP_TPT]"; 72 break; 73 74 case M_SCTP_TPT: 75 t = "TransportType[SCTP_TPT]"; 76 break; 77 78 case M_ATM_TPT: 79 t = "TransportType[ATM_TPT]"; 80 break; 81 82 case M_MTP3B_TPT: 83 t = "TransportType[MTP3B_TPT]"; 84 break; 85 default: 86 t = "TransportType[" + this.transport_type + "]"; 87 } 88 return t; 89 } 90 91}