Merge remote-tracking branch 'remotes/origin/master' into ks-20191119-scheduler

This commit is contained in:
Ken Stevens 2019-12-05 21:45:31 -05:00
commit 9e4f57836f
1 changed files with 12 additions and 0 deletions

View File

@ -23,6 +23,7 @@ package ca.uhn.fhir.jpa.delete;
import ca.uhn.fhir.jpa.util.DeleteConflict;
import org.apache.commons.lang3.Validate;
import org.hl7.fhir.instance.model.api.IIdType;
import org.springframework.util.Assert;
import java.util.ArrayList;
import java.util.HashSet;
@ -81,19 +82,30 @@ public class DeleteConflictList implements Iterable<DeleteConflict> {
private final int myOriginalRemoveModCont = myRemoveModCount;
private int myNextIndex = 0;
private boolean myLastOperationWasNext;
@Override
public boolean hasNext() {
checkForCoModification();
myLastOperationWasNext = false;
return myNextIndex < myList.size();
}
@Override
public DeleteConflict next() {
checkForCoModification();
myLastOperationWasNext = true;
return myList.get(myNextIndex++);
}
@Override
public void remove() {
Assert.isTrue(myLastOperationWasNext);
myNextIndex--;
myList.remove(myNextIndex);
myLastOperationWasNext = false;
}
private void checkForCoModification() {
Validate.isTrue(myOriginalRemoveModCont == myRemoveModCount);
}