question: public void mergeBackendNotes ( List < Note > remoteNotes ) { List < Note > toMergeNotes = new ArrayList < > ( ) ; Map < String , Note > remoteNotesMap = new HashMap < > ( ) ; for ( Note note : remoteNotes ) { remoteNotesMap . put ( note . getBackendId ( ) , note ) ; } List < Note > localNotes = noteDao . queryByBackendIds ( remoteNotesMap . keySet ( ) ) ; Map < String , Note > localNotesMap = new HashMap < > ( ) ; for ( Note localNote : localNotes ) { localNotesMap . put ( localNote . getBackendId ( ) , localNote ) ; } for ( Note remoteNote : remoteNotes ) { Note localNote = localNotesMap . get ( remoteNote . getBackendId ( ) ) ; if ( localNote != null ) { remoteNote . setId ( localNote . getId ( ) ) ; } toMergeNotes . add ( remoteNote ) ; } saveNotes ( toMergeNotes ) ; }
target:  Merge Notes in parameters to those already in the database.