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;
}

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 ; }
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 .
