use of java.util.function.LongConsumer in project jdk8u_jdk by JetBrains.
the class LongPipeline method forEachWithCancel.
@Override
final void forEachWithCancel(Spliterator<Long> spliterator, Sink<Long> sink) {
Spliterator.OfLong spl = adapt(spliterator);
LongConsumer adaptedSink = adapt(sink);
do {
} while (!sink.cancellationRequested() && spl.tryAdvance(adaptedSink));
}
use of java.util.function.LongConsumer in project jdk8u_jdk by JetBrains.
the class SerializedLambdaTest method testDiscardReturnBound.
//Test throwing away return type
public void testDiscardReturnBound() throws IOException, ClassNotFoundException {
List<String> list = new ArrayList<>();
Consumer<String> c = (Consumer<String> & Serializable) list::add;
assertSerial(c, cc -> {
assertTrue(cc instanceof Consumer);
});
AtomicLong a = new AtomicLong();
LongConsumer lc = (LongConsumer & Serializable) a::addAndGet;
assertSerial(lc, plc -> {
plc.accept(3);
});
}
use of java.util.function.LongConsumer in project Bytecoder by mirkosertic.
the class LongPipeline method forEachWithCancel.
@Override
final boolean forEachWithCancel(Spliterator<Long> spliterator, Sink<Long> sink) {
Spliterator.OfLong spl = adapt(spliterator);
LongConsumer adaptedSink = adapt(sink);
boolean cancelled;
do {
} while (!(cancelled = sink.cancellationRequested()) && spl.tryAdvance(adaptedSink));
return cancelled;
}
use of java.util.function.LongConsumer in project fmv by f-agu.
the class PIDProcessOperator method consume.
// *********************************************
/**
* @param process
* @param cls
* @param field
* @throws NoSuchFieldException
* @throws IllegalAccessException
*/
private void consume(Process process, Class<? extends Process> cls, String field) throws NoSuchFieldException, IllegalAccessException {
Field f = cls.getDeclaredField(field);
f.setAccessible(true);
pid = f.getLong(process);
for (LongConsumer pidConsumer : pidConsumers) {
pidConsumer.accept(pid);
}
f.setAccessible(false);
}
use of java.util.function.LongConsumer in project robozonky by RoboZonky.
the class EntityCollectionPageSourceTest method firstPage.
@Test
void firstPage() {
final List<Integer> allResults = FUNCTION.apply(null);
final List<Integer> subpage = allResults.subList(0, PAGE_SIZE);
final PaginatedApi<Integer, Object> api = mock(PaginatedApi.class);
when(api.execute(eq(FUNCTION), eq(SELECT), eq(ORDERING), eq(0), eq(PAGE_SIZE))).thenReturn(new PaginatedResult<>(subpage, allResults.size()));
final PageSource<Integer> source = new EntityCollectionPageSource<Integer, Object>(api, FUNCTION, SELECT, ORDERING, PAGE_SIZE);
final LongConsumer consumer = mock(LongConsumer.class);
final List<Integer> result = source.fetch(0, 1, consumer);
assertThat(result).containsExactly(subpage.toArray(new Integer[PAGE_SIZE]));
verify(consumer).accept(eq((long) allResults.size()));
}
Aggregations