UpdateOp update = updateOps.get(i);
T target = collection.newDocument(this);
UpdateUtils.applyChanges(target, update, comparator);
docs.add(target);
for (Entry<Key, Operation> entry : update.getChanges().entrySet()) {
Key k = entry.getKey();
Operation op = entry.getValue();
switch (op.type) {
case SET:
case MAX:
case INCREMENT: {
inserts[i].put(k.toString(), op.value);
break;
}
case SET_MAP_ENTRY: {
Revision r = k.getRevision();
if (r == null) {
throw new IllegalStateException(
"SET_MAP_ENTRY must not have null revision");
}
DBObject value = new RevisionEntry(r, op.value);
inserts[i].put(k.getName(), value);
break;
}
case REMOVE_MAP_ENTRY:
// nothing to do for new entries
break;