question: private Boolean filterExistingItems ( List < PostItem > postItems , PostItem item ) { if ( postItems . contains ( item ) ) { int i = postItems . indexOf ( item ) ; postItems . remove ( i ) ; postItems . add ( i , item ) ; return false ; } return true ; }
target:  This function replaces the old item in the list with the new one only if both items have the same id. If replaced, filter out the emitted item. If not, return true to include it. Note: equals method of PostItem is overriden to only return true if ID are the same.