private NamedOutputBlockContext findAndRemoveBlock ( List < NamedOutputBlockContext > blocks , String name ) { if ( blocks == null ) { return null ; } Iterator < NamedOutputBlockContext > blockIter = blocks . iterator ( ) ; while ( blockIter . hasNext ( ) ) { NamedOutputBlockContext block = blockIter . next ( ) ; String blockName = name ( block ) ; if ( name . equals ( blockName ) ) { blockIter . remove ( ) ; return block ; } } return null ; }
Find and remove block with specific name