You can add constants and replace with the following form:
switch (userData.status) { case UserData.STATUS_DISCONNECTED: // isDisconnected code break; case UserData.STATUS_MANAGER_ENTERED: // ... break; default: Log.d(TAG, "не обработанный статус") }
.resume() for condition
In the end, something like this should come out:
AsyncResponse asyncResponse = waiters.remove(userData.getClientId()); switch (userData.status) { case UserDate.STATUS_MANAGER_ENTERED: response[0] = getPersonEntered(userData); userData.setManagerEntered(false); break; case UserData.STATUS_MESSAGE_RECEVE: response[0] = getChatReceived(userData); break; case UserData.STATUS_DISCONNECTED: response[0] = getCallDisconnected(userData); userData.setDisconnected(false); System.out.println("isdisconnect"); break; default: System.out.println("Untreated status: " + userData.status); } asyncResponse.resume(response[0]);
src / com / example / UserData
// public class UserData extends otherUserData { public class UserData { private int _i = 0; static final int STATUS_DISCONNECTED = _i++; static final int STATUS_MANAGER_ENTERED = _i++; static final int STATUS_MESSAGE_RECEVE = _i++ private int status; public UserData() { // Обработка объекта } }
Java is generally a language in which you can't do without your own classes. It seems that userData is already some kind of class in which there is a status and this class could be expanded and created its own class for convenience.
Here I am to what.
static final enum Status { DISCONNECTED, MANAGER_ENTERED, MESSAGE_RECEVE }
while Status is already an object, not an int.
http://www.quizful.net/post/java_enums
Learn more about enum in java