/** * Merge the "after" values from the given {@link RawContactDeltaList}, discarding any * previous "after" states. This is typically used when re-parenting user * edits onto an updated {@link RawContactDeltaList}. */ public static RawContactDeltaList mergeAfter(RawContactDeltaList local, RawContactDeltaList remote) { if (local == null) local = new RawContactDeltaList(); // For each entity in the remote set, try matching over existing for (RawContactDelta remoteEntity : remote) { final Long rawContactId = remoteEntity.getValues().getId(); // Find or create local match and merge final RawContactDelta localEntity = local.getByRawContactId(rawContactId); final RawContactDelta merged = RawContactDelta.mergeAfter(localEntity, remoteEntity); if (localEntity == null && merged != null) { // No local entry before, so insert local.add(merged); } } return local; }