question: public static void executeInBulk ( @ NotNull Document document , final boolean executeInBulk , @ NotNull Runnable task ) { if ( ! ( document instanceof DocumentEx ) ) { task . run ( ) ; return ; } DocumentEx documentEx = ( DocumentEx ) document ; if ( executeInBulk == documentEx . isInBulkUpdate ( ) ) { task . run ( ) ; return ; } documentEx . setInBulkUpdate ( executeInBulk ) ; try { task . run ( ) ; } finally { documentEx . setInBulkUpdate ( ! executeInBulk ) ; } }
target:  Ensures that given task is executed when given document is at the given 'in bulk' mode.