public List<Product> getNotLinkedProducts(String clientId, Integer providerId, String words) { List<LinkedProductEntry> entries = linkedEntryRepository.find(new LinkedEntryCondition(providerId)); Set<String> linkedNames = new HashSet<String>(); for (LinkedProductEntry entry : entries) linkedNames.add(entry.name); List<Product> notLinkedProducts = new ArrayList<>(); ProductSource source = new ProviderSourceStub(); for (Product product : source.get(providerId)) if (!linkedNames.contains(product.name) && contain(product.name, words)) notLinkedProducts.add(product); return notLinkedProducts; }