/protocols/jain-megaco/megaco-api/src/main/java/javax/megaco/ReturnStatus.java
Java | 66 lines | 46 code | 20 blank | 0 comment | 2 complexity | 16cdbe4a2ddb46e33a59822fc593f5c9 MD5 | raw file
1package javax.megaco; 2 3public class ReturnStatus { 4 5 public static final int M_SUCCESS = 1; 6 public static final int M_FAILURE = 2; 7 8 public static final ReturnStatus SUCCESS = new ReturnStatus(M_SUCCESS); 9 10 public static final ReturnStatus FAILURE = new ReturnStatus(M_FAILURE); 11 12 private int return_status; 13 14 private ReturnStatus(int return_status) { 15 this.return_status = return_status; 16 17 } 18 19 public int getReturnStatus() { 20 return this.return_status; 21 } 22 23 public static final ReturnStatus getObject(int value) throws IllegalArgumentException { 24 ReturnStatus r = null; 25 switch (value) { 26 case M_SUCCESS: 27 r = SUCCESS; 28 break; 29 30 case M_FAILURE: 31 r = FAILURE; 32 break; 33 default: 34 throw new IllegalArgumentException("No ReturnStatus for value " + value); 35 36 } 37 38 return r; 39 } 40 41 private Object readResolve() { 42 43 return this.getObject(this.return_status); 44 45 } 46 47 @Override 48 public String toString() { 49 String r = null; 50 switch (this.return_status) { 51 case M_SUCCESS: 52 r = "ReturnStatus[SUCCESS]"; 53 break; 54 55 case M_FAILURE: 56 r = "ReturnStatus[FAILURE]"; 57 break; 58 default: 59 r = "ReturnStatus[" + this.return_status + "]"; 60 61 } 62 63 return r; 64 } 65 66}