PageRenderTime 30ms CodeModel.GetById 19ms app.highlight 8ms RepoModel.GetById 2ms app.codeStats 0ms

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