Я делаю отдых, чтобы обновить эти 3 поля, какое поле для обновления определено, если это поле отсутствует на карте хэша, и по умолчанию оно обновляет «AA»цикл в зависимости от количества дней
Каждый раз, когда я делаю вызов, счетчик также увеличивается на сервере. поэтому после 3 запусков все поля находятся на сервере, и он всегда обновляет «AA», потому что он по умолчанию, теперь я хочу, чтобы поле для обновления выбиралось счетчиком. Таким образом, поток продолжается как AA, BB, CC - AA, BB, CC - AA, BB, CC. Как?
//on 1st update call,it updates AA and Counter is set to =1
//2nd update call,it update BB = Counter is set to =2
//3rd update call,it update CC = Counter is set to =3
//4th update call,it update AA = Counter is set to =4
//5th update call,it update AA = Counter is set to =5
//6th update call,it update AA = Counter is set to =6
if (fieldValues.containsKey("COUNTER")) {
counter= fieldValues.get("COUNTER");
}// how can we use this counter to select the next field
HashMap<String, String> fieldValues = [{key,value},{key,value},{key,value}......]
String [] FieldsToUpdate = ["AA","BB","CC"];
String xxxFieldToUpdate = FieldsToUpdate[0];// so default is "AA"
for(String Field : FieldsToUpdate){
if(!fieldValues.containsKey(Field)){
xxxFieldToUpdate = Field.trim();
break;
}
}
// Solved by calling a new method which reset the Iterator //
String fieldToUpdate = "";
counter= fieldValues.get("COUNTER");
Iterator it = fieldsToUpdate.iterator();
for(int i=0; i<counter; i++) {
if(!it.hasNext()) // if you are at the end of the list reset iterator
it = fieldsToUpdate.iterator();
String res = it.next().toString();
fieldToUpdate = res;
}
return fieldToUpdate;
Я решить мою проблему, смотрите мои Изменить на оригинальный вопрос. Спасибо всем – Lucky