public int replaceIf ( Predicate < Message > filter , Message replacement , boolean match_all ) { if ( filter == null ) return 0 ; int matched = 0 ; for ( int i = 0 ; i < index ; i ++ ) { if ( filter . test ( messages [ i ] ) ) { messages [ i ] = replacement ; matched ++ ; if ( ! match_all ) break ; } } return matched ; }
Replaces all messages that match a given filter with a replacement message