if (comparisonResult < 0) {
// The from entity doesn't exist on the to source therefore
// has been deleted. We don't know when the entity was
// deleted so set the delete time to the current time.
changeSink.process(
new ChangeContainer(
timestampSetter.updateTimestamp(fromEntityContainer),
ChangeAction.Delete));
fromEntityContainer = null;
} else if (comparisonResult > 0) {
// The to entity doesn't exist on the from source therefore has
// been created.
changeSink.process(new ChangeContainer(toEntityContainer, ChangeAction.Create));
toEntityContainer = null;
} else {
// The entity exists on both sources, therefore we must
// compare
// the entities directly. If there is a difference, the
// entity has been modified.
if (!fromEntityContainer.getEntity().equals(toEntityContainer.getEntity())) {
changeSink.process(new ChangeContainer(toEntityContainer, ChangeAction.Modify));
}
fromEntityContainer = null;
toEntityContainer = null;
}
}
// Any remaining "from" entities are deletes.
while (fromEntityContainer != null || fromPostbox.hasNext()) {
if (fromEntityContainer == null) {
fromEntityContainer = fromPostbox.getNext();
}
// The from entity doesn't exist on the to source therefore
// has been deleted. We don't know when the entity was
// deleted so set the delete time to the current time.
changeSink.process(
new ChangeContainer(
timestampSetter.updateTimestamp(fromEntityContainer),
ChangeAction.Delete));
fromEntityContainer = null;
}
// Any remaining "to" entities are creates.
while (toEntityContainer != null || toPostbox.hasNext()) {
if (toEntityContainer == null) {
toEntityContainer = toPostbox.getNext();
}
changeSink.process(new ChangeContainer(toEntityContainer, ChangeAction.Create));
toEntityContainer = null;
}
changeSink.complete();
fromPostbox.outputComplete();