if (last < 0) { //optimize the most common case
_requests.add(request);
return;
}
final AuRequest req2 = (AuRequest)_requests.get(last);
if ((req2.getOptions() & AuRequest.BUSY_IGNORE) != 0) {
_requests.remove(last); //drop it
if (last == 0) {
_requests.add(request);
return;
}
}
}
final String name = request.getCommand();
final int opts = request.getOptions();
//Since 3.0.2, redundant CTRL_GROUP is removed at the client
//case 2, DUPLICATE_IGNORE: drop existent request if they are the same
//as the arrival.
if ((opts & AuRequest.DUPLICATE_IGNORE) != 0) {
final String uuid = getUuid(request);
for (Iterator it = _requests.iterator(); it.hasNext();) {
final AuRequest req2 = (AuRequest)it.next();
if (req2.getCommand().equals(name)
&& Objects.equals(getUuid(req2), uuid)) {
it.remove(); //drop req2 (the old one)
break; //no need to iterate because impossible to have more
}
}
//Case 3, REPEAT_IGNORE: drop existent if the immediate
//following is the same
} else if ((opts & AuRequest.REPEAT_IGNORE) != 0) {
final int last = _requests.size() - 1;
final AuRequest req2 = (AuRequest)_requests.get(last);
if (req2.getCommand().equals(name)
&& Objects.equals(getUuid(req2), getUuid(request))) {
_requests.remove(last);
}
}