/** * Gets an {@link Iterable} that wraps an iterator. The returned {@link Iterable} can be * used for a single iteration. * * @param <E> the element type * @param iterator the iterator to use, may not be null * @return a new, single use {@link Iterable} * @throws NullPointerException if iterator is null */ public static <E> Iterable<E> asIterable(final Iterator<? extends E> iterator) { if (iterator == null) { throw new NullPointerException("Iterator must not be null"); } return new IteratorIterable<>(iterator, false); }
/** * Constructs a new <code>IteratorIterable</code> that will use the given * iterator. * * @param iterator the iterator to use. * @param multipleUse <code>true</code> if the new iterable can be used in multiple iterations */ public IteratorIterable(final Iterator<? extends E> iterator, final boolean multipleUse) { super(); if (multipleUse && !(iterator instanceof ResettableIterator)) { this.iterator = new ListIteratorWrapper<>(iterator); } else { this.iterator = iterator; } this.typeSafeIterator = createTypesafeIterator(this.iterator); }
/** * Gets an iterable that wraps an iterator. The returned iterable can be * used for multiple iterations. * * @param <E> the element type * @param iterator the iterator to use, may not be null * @return a new, multiple use iterable * @throws NullPointerException if iterator is null */ public static <E> Iterable<E> asMultipleUseIterable(final Iterator<? extends E> iterator) { if (iterator == null) { throw new NullPointerException("Iterator must not be null"); } return new IteratorIterable<>(iterator, true); }
/** * Append a line break. * * @return text run representing this line break ('\n'). */ public XDDFTextRun appendLineBreak() { CTTextLineBreak br = _p.addNewBr(); // by default, line break has the font properties of the last text run for (XDDFTextRun tr : new IteratorIterable<>(new ReverseListIterator<>(_runs))) { CTTextCharacterProperties prevProps = tr.getProperties(); // let's find one that is not undefined if (prevProps != null) { br.setRPr((CTTextCharacterProperties) prevProps.copy()); break; } } XDDFTextRun run = new XDDFTextRun(br, this); _runs.add(run); return run; }
mailSender.sendAsynchronously(new IteratorIterable<MimeMessage>(messageIterator), session, mailListener); } catch (Exception e) { throw new WatchListException(String.format("Failed to send notification to subscribers [%s]", subscribers),
/** * Append a line break. * * @return text run representing this line break ('\n'). */ public XDDFTextRun appendLineBreak() { CTTextLineBreak br = _p.addNewBr(); // by default, line break has the font properties of the last text run for (XDDFTextRun tr : new IteratorIterable<>(new ReverseListIterator<>(_runs))) { CTTextCharacterProperties prevProps = tr.getProperties(); // let's find one that is not undefined if (prevProps != null) { br.setRPr((CTTextCharacterProperties) prevProps.copy()); break; } } XDDFTextRun run = new XDDFTextRun(br, this); _runs.add(run); return run; }