/** * Pass all the elements of the iterable to the supplied {@link Consumer}. Guarantees that the iterator used will be * closed correctly * * @param iterable containing elements of type T * @param sink that will consume the elements */ public static <T> void apply(final EnclosedIterable<T> iterable, final Consumer<T> sink) { iterable.foreach(sink); }
public boolean isEmpty() { return results.isEmpty(); } }
/** * Get an {@link ArrayList} of the contents of the supplied {@link EnclosedIterable} * transformed by the supplied transform function into the new type O. * * @return a mutable {@link ArrayList} containing all elements of the iterable. */ public static <I, O> List<O> toList(final EnclosedIterable<I> iterable, final Function<I, O> transformer) { final List<O> result = new ArrayList<>(iterable.size()); iterable.foreach(element -> result.add(transformer.get(element))); return result; } }
public int size() { return delegate.size(); } }
public int size() { return results.size(); }
public final void foreach(final Consumer<E> sink) { results.foreach(sink); }
private int[] sizes() { final int[] sizes = new int[retrievers.size()]; int i = 0; for (final Retriever<? extends SharedEntity> element : retrievers.values()) { sizes[i++] = element.getAll().size(); } return sizes; }
public boolean isEmpty() { return delegate.isEmpty(); }
/** * Get an {@link ArrayList} of the contents of the supplied {@link EnclosedIterable} * * @return a mutable {@link ArrayList} containing all elements of the iterable. */ public List<T> get(final EnclosedIterable<T> iterable) { final List<T> result = new ArrayList<>(); iterable.foreach(result::add); return result; } }
public boolean isEmpty() { for (final Retriever<? extends SharedEntity> element : retrievers.values()) { if (!element.getAll().isEmpty()) { return false; } } return true; }
private static Set<Long> getIssuesIdsForAttachments(final EnclosedIterable<Attachment> attachments) { final Set<Long> issuesId = new HashSet<Long>(); attachments.foreach(new Consumer<Attachment>() { @Override public void consume(@Nonnull final Attachment attachment) { issuesId.add(attachment.getIssueId()); } }); return issuesId; }
@Override public Collection<SearchRequest> getFavouriteFilters(final ApplicationUser user) { final Collection<Long> ids = getFavouriteIds(user); final List<SearchRequest> results = new ArrayList<>(ids.size()); searchRequestManager.getSearchRequests(user, new DefaultSharedEntitySearcher.Ids(ids, false)).foreach(results::add); Collections.sort(results, FilterNameComparator.COMPARATOR); return results; }
private void copyAttachmentsToZipFile(final Issue issue, final UniqueFileNameGenerator uniqueFileNameGenerator, final ZipArchiveOutputStream out) { final EnclosedIterable<Attachment> attachmentsOfIssue = bulkAttachmentOperations.getAttachmentOfIssue(issue); attachmentsOfIssue.foreach(copyAttachmentToOutput(uniqueFileNameGenerator, out)); }
public void foreach(final Consumer<O> sink) { delegate.foreach(element -> sink.consume(transformer.get(element))); }
@Override public EnclosedIterable<SearchRequest> get(final RetrievalDescriptor descriptor) { // get SearchRequests that haven't been loaded to the cache yet and populate the cache final DefaultSharedEntitySearcher.Ids searchRequestsFromDb = new DefaultSharedEntitySearcher.Ids( descriptor.getIds().stream().filter(id -> !cacheById.containsKey(id)) .collect(toImmutableListWithSizeOf(descriptor.getIds())), false); delegateStore.get(searchRequestsFromDb).foreach(searchRequest -> cacheById.put(searchRequest.getId(), CacheObject.wrap(searchRequest))); // read all from the cache return CollectionEnclosedIterable.from(descriptor.getIds().stream().filter(cacheById::containsKey).map(cacheById::get).filter(CacheObject::hasValue) .map(CacheObject::getValue).collect(toImmutableListWithSizeOf(descriptor.getIds()))); }
iterable.foreach(new Consumer<PortalPage>()
ConsumeAllAttachmentKeys.getAttachmentsWithKeys(bulkAttachmentOperations.getAllAttachments(), issueManager).foreach( new Consumer<Pair<Attachment, AttachmentKey>>()
issues.foreach(new Consumer<Issue>()