* {@inheritDoc}
*/
public boolean hasNext() {
while (!nextValueLoaded && sourceIterator.hasNext()) {
List<ChangeContainer> changeList;
ChangeContainer changeContainer;
boolean createdPreviously;
// Get the next change list from the underlying stream.
changeList = sourceIterator.next();
// Check the first node, if it has a version greater than 1 the node
// existed prior to the interval beginning and therefore cannot be a
// create.
createdPreviously = (changeList.get(0).getEntityContainer().getEntity().getVersion() > 1);
// Get the most current change.
changeContainer = changeList.get(changeList.size() - 1);
// The entity has been modified if it is a create/modify and was created previously.
// It is a create if it is create/modify and was NOT created previously.
// It is a delete if it is a delete and was created previously.
// No action if it is a delete and was NOT created previously.
if (!ChangeAction.Delete.equals(changeContainer.getAction()) && createdPreviously) {
nextValue = new ChangeContainer(changeContainer.getEntityContainer(), ChangeAction.Modify);
nextValueLoaded = true;
} else if (!ChangeAction.Delete.equals(changeContainer.getAction()) && !createdPreviously) {
nextValue = new ChangeContainer(changeContainer.getEntityContainer(), ChangeAction.Create);
nextValueLoaded = true;
} else if (ChangeAction.Delete.equals(changeContainer.getAction()) && createdPreviously) {
nextValue = new ChangeContainer(changeContainer.getEntityContainer(), ChangeAction.Delete);
nextValueLoaded = true;
}
}
return nextValueLoaded;