int currentStatus = currentState.getStatus();
boolean keepChanges = Status.isTransient(currentStatus) || Status.isStale(currentStatus);
MergeResult mergeResult = currentState.merge(state, keepChanges);
if (currentStatus == Status.INVALIDATED) {
currentState.setStatus(Status.EXISTING);
} else if (mergeResult.modified()) {
currentState.setStatus(Status.MODIFIED);
} // else: not modified. just leave status as it is.
mergeResult.dispose();
}
}