@Test public void testItemExists() throws Exception { final SearchResult searchResult = createSearchResult(1); final String code = searchResult.code; productList.addProduct(searchResult); assertTrue(productList.itemExists(code)); }
public boolean itemExists(String code) { for (SearchResult p : searchResults) { if (p != null) { if (p.code.equals(code)) { searchResults.remove(p); searchResults.add(0, p); notifyOnChanged(); return true; } } } return false; }
ProductList { public boolean itemExists(String code) { for (SearchResult p : searchResults) { if (p != null) { if (p.code.equals(code)) { searchResults.remove(p); searchResults.add(0, p); notifyOnChanged(); return true; } } } return false; } }
ProductList { public boolean itemExists(String code) { for (SearchResult p : searchResults) { if (p != null) { if (p.code.equals(code)) { searchResults.remove(p); searchResults.add(0, p); notifyOnChanged(); return true; } } } return false; } private  ProductList(@NonNull final List<SearchResult> searchResults); }
ProductList { public boolean itemExists(String code) { for (SearchResult p : searchResults) { if (p != null) { if (p.code.equals(code)) { searchResults.remove(p); searchResults.add(0, p); notifyOnChanged(); return true; } } } return false; } private  ProductList(@NonNull final List<SearchResult> searchResults); static ProductList create(@Nullable Bundle bundle); void setOnProductListChanged(@Nullable OnProductListChanged onProductListChanged); void writeToBundle(@NonNull final Bundle bundle); void addProduct(SearchResult searchResult); void createProductPlaceholder(); void removeProductPlaceholder(); boolean itemExists(String code); int size(); SearchResult get(int position); }
ProductList { public boolean itemExists(String code) { for (SearchResult p : searchResults) { if (p != null) { if (p.code.equals(code)) { searchResults.remove(p); searchResults.add(0, p); notifyOnChanged(); return true; } } } return false; } private  ProductList(@NonNull final List<SearchResult> searchResults); static ProductList create(@Nullable Bundle bundle); void setOnProductListChanged(@Nullable OnProductListChanged onProductListChanged); void writeToBundle(@NonNull final Bundle bundle); void addProduct(SearchResult searchResult); void createProductPlaceholder(); void removeProductPlaceholder(); boolean itemExists(String code); int size(); SearchResult get(int position);  }