Replacing ItemInfoMatcher with predicate

This removed unnecessary componentName lookups when it
is not required. Many checks just rely on IDs and
userHandle

Bug: 231153610
Test: Presubmit
Change-Id: Ief93954abc5861062a9f55dc2ef181d3de106c62
This commit is contained in:
Sunny Goyal
2022-05-02 10:00:07 -07:00
parent 34f51fbfc4
commit 32084d49d3
18 changed files with 106 additions and 147 deletions
@@ -53,6 +53,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
@@ -278,10 +279,9 @@ public class ModelWriter {
/**
* Removes all the items from the database matching {@param matcher}.
*/
public void deleteItemsFromDatabase(ItemInfoMatcher matcher) {
public void deleteItemsFromDatabase(Predicate<ItemInfo> matcher) {
deleteItemsFromDatabase(StreamSupport.stream(mBgDataModel.itemsIdMap.spliterator(), false)
.filter(matcher::matchesInfo)
.collect(Collectors.toList()));
.filter(matcher).collect(Collectors.toList()));
}
/**