use of java.util.Spliterator in project webprotege by protegeproject.
the class TagRepositoryImpl method saveTags.
public void saveTags(@Nonnull Iterable<Tag> tags) {
writeLock.lock();
try {
checkNotNull(tags);
Spliterator<Tag> spliterator = tags.spliterator();
List<WriteModel<Document>> updates = stream(spliterator, false).map(tag -> new ReplaceOneModel<>(toFilter(tag), toDocument(tag), upsert())).collect(toList());
BulkWriteResult bulkWriteResult = getCollection().bulkWrite(updates);
} finally {
writeLock.unlock();
}
}
use of java.util.Spliterator in project nexus-public by sonatype.
the class OrientMetadataRebuilderTest method infiniteIterator.
private Iterable infiniteIterator(final Object returnItem) {
Iterable iterable = mock(Iterable.class);
Iterator iterator = mock(Iterator.class);
Spliterator spliterator = mock(Spliterator.class);
when(iterable.spliterator()).thenReturn(spliterator);
when(iterable.iterator()).thenReturn(iterator);
when(iterator.hasNext()).thenReturn(true);
when(iterator.next()).thenReturn(returnItem);
return iterable;
}
use of java.util.Spliterator in project nexus-public by sonatype.
the class OrientMetadataRebuilderTest method iteratorWithItems.
private Iterable iteratorWithItems(final Object... returnItems) {
int numItems = returnItems.length;
Iterable iterable = mock(Iterable.class);
Iterator iterator = mock(Iterator.class);
Spliterator spliterator = Spliterators.spliterator(returnItems, 0);
final int[] iteratorCounter = { 0 };
when(iterable.spliterator()).thenReturn(spliterator);
when(iterable.iterator()).thenReturn(iterator);
when(iterator.hasNext()).thenAnswer((Answer<Boolean>) invocation -> iteratorCounter[0] < numItems);
when(iterator.next()).thenAnswer((Answer<?>) invocation -> returnItems[iteratorCounter[0]++]);
return iterable;
}
use of java.util.Spliterator in project openj9 by eclipse-openj9.
the class StringStreams method testStringCharsSpliterator.
@Test
public void testStringCharsSpliterator() {
Spliterator.OfInt s = DIGITS.codePoints().spliterator();
final ArrayList<Integer> actualIntegers = new ArrayList<>();
s.forEachRemaining((IntConsumer) i -> actualIntegers.add(Integer.valueOf(i)));
for (int c = 0; c < DIGITS.length(); ++c) {
assertEquals(actualIntegers.get(c), Integer.valueOf(DIGITS.codePointAt(c)), // $NON-NLS-1$
"Wrong value at position " + c);
}
}
use of java.util.Spliterator in project openj9 by eclipse-openj9.
the class StringStreams method testStringCodePointsSpliterator.
@Test
public void testStringCodePointsSpliterator() {
Spliterator.OfInt s = DIGITS.chars().spliterator();
final ArrayList<Integer> actualIntegers = new ArrayList<>();
s.forEachRemaining((IntConsumer) i -> actualIntegers.add(Integer.valueOf(i)));
checkDigitsOrdered(DIGITS, actualIntegers);
}
Aggregations