public List < ? extends ListCommand > repairRemoteCommandVersion ( final List < ? extends ListCommand > indexRepairedRemoteCommands , final List < ListCommand > versionRepairedLocalCommands ) { final int commandCount = indexRepairedRemoteCommands . size ( ) ; final ListCommand lastLocalCommand = versionRepairedLocalCommands . get ( versionRepairedLocalCommands . size ( ) - 1 ) ; if ( commandCount == 0 ) { return asList ( new RemoveFromList ( lastLocalCommand . getListId ( ) , new ListVersionChange ( randomUUID ( ) , lastLocalCommand . getListVersionChange ( ) . getToVersion ( ) ) , 0 , 0 ) ) ; } final List < ListCommand > repaired = new ArrayList < ListCommand > ( commandCount ) ; for ( int i = 0 ; i < commandCount - 1 ; i ++ ) { repaired . add ( indexRepairedRemoteCommands . get ( i ) ) ; } repaired . add ( repairCommand ( indexRepairedRemoteCommands . get ( commandCount - 1 ) , randomUUID ( ) , lastLocalCommand . getListVersionChange ( ) . getToVersion ( ) ) ) ; return repaired ; }
Updates the version of the remote commands that should be executed locally to ensure that the local list version equals the version that is resent to the server when they are executed .