Skip to content

Commit

Permalink
Add XTerminatingOperationFactory, Work on #44
Browse files Browse the repository at this point in the history
  • Loading branch information
minborg committed Dec 30, 2020
1 parent 3c71cd7 commit 1dfef51
Show file tree
Hide file tree
Showing 14 changed files with 1,298 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* JPAstreamer - Express JPA queries with Java Streams
* Copyright (c) 2020-2020, Speedment, Inc. All Rights Reserved.
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE
*/
package com.speedment.jpastreamer.pipeline.terminal;

import java.util.*;
import java.util.function.*;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;

public interface DoubleTerminalOperationFactory extends BaseStreamTerminalOperationFactory {

TerminalOperation<DoubleStream, Void> createForEach(DoubleConsumer action);

TerminalOperation<DoubleStream, Void> createForEachOrdered(DoubleConsumer action);

TerminalOperation<DoubleStream, double[]> acquireToArray();

TerminalOperation<DoubleStream, Double> createReduce(double identity, DoubleBinaryOperator op);

TerminalOperation<DoubleStream, OptionalDouble> createReduce(DoubleBinaryOperator op);

<R> TerminalOperation<DoubleStream, R> createCollect(Supplier<R> supplier,
ObjDoubleConsumer<R> accumulator,
BiConsumer<R, R> combiner);

TerminalOperation<DoubleStream, Double> acquireSum();

TerminalOperation<DoubleStream, OptionalDouble> acquireMin();

TerminalOperation<DoubleStream, OptionalDouble> acquireMax();

TerminalOperation<DoubleStream, Long> acquireCount();


TerminalOperation<DoubleStream, OptionalDouble> acquireAverage();

TerminalOperation<DoubleStream, DoubleSummaryStatistics> acquireSummaryStatistics();


TerminalOperation<DoubleStream, Boolean> createAnyMatch(DoublePredicate predicate);

TerminalOperation<DoubleStream, Boolean> createAllMatch(DoublePredicate predicate);

TerminalOperation<DoubleStream, Boolean> createNoneMatch(DoublePredicate predicate);

TerminalOperation<DoubleStream, OptionalDouble> acquireFindFirst();

TerminalOperation<DoubleStream, OptionalDouble> acquireFindAny();

@SuppressWarnings("unchecked")
@Override
TerminalOperation<DoubleStream, PrimitiveIterator.OfDouble> acquireIterator();

@SuppressWarnings("unchecked")
@Override
TerminalOperation<DoubleStream, Spliterator.OfDouble> acquireSpliterator();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* JPAstreamer - Express JPA queries with Java Streams
* Copyright (c) 2020-2020, Speedment, Inc. All Rights Reserved.
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE
*/
package com.speedment.jpastreamer.pipeline.terminal;

import java.util.*;
import java.util.function.*;
import java.util.stream.BaseStream;
import java.util.stream.IntStream;

public interface IntTerminalOperationFactory extends BaseStreamTerminalOperationFactory {

TerminalOperation<IntStream, Void> createForEach(IntConsumer action);

TerminalOperation<IntStream, Void> createForEachOrdered(IntConsumer action);

TerminalOperation<IntStream, int[]> acquireToArray();

TerminalOperation<IntStream, Integer> createReduce(int identity, IntBinaryOperator op);

TerminalOperation<IntStream, OptionalInt> createReduce(IntBinaryOperator op);

<R> TerminalOperation<IntStream, R> createCollect(Supplier<R> supplier,
ObjIntConsumer<R> accumulator,
BiConsumer<R, R> combiner);

TerminalOperation<IntStream, Integer> acquireSum();

TerminalOperation<IntStream, OptionalInt> acquireMin();

TerminalOperation<IntStream, OptionalInt> acquireMax();

TerminalOperation<IntStream, Long> acquireCount();


TerminalOperation<IntStream, OptionalDouble> acquireAverage();

TerminalOperation<IntStream, IntSummaryStatistics> acquireSummaryStatistics();


TerminalOperation<IntStream, Boolean> createAnyMatch(IntPredicate predicate);

TerminalOperation<IntStream, Boolean> createAllMatch(IntPredicate predicate);

TerminalOperation<IntStream, Boolean> createNoneMatch(IntPredicate predicate);

TerminalOperation<IntStream, OptionalInt> acquireFindFirst();

TerminalOperation<IntStream, OptionalInt> acquireFindAny();

@SuppressWarnings("unchecked")
@Override
TerminalOperation<IntStream, PrimitiveIterator.OfInt> acquireIterator();

@SuppressWarnings("unchecked")
@Override
TerminalOperation<IntStream, Spliterator.OfInt> acquireSpliterator();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* JPAstreamer - Express JPA queries with Java Streams
* Copyright (c) 2020-2020, Speedment, Inc. All Rights Reserved.
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* See: https://github.com/speedment/jpa-streamer/blob/master/LICENSE
*/
package com.speedment.jpastreamer.pipeline.terminal;

import java.util.*;
import java.util.function.*;
import java.util.stream.LongStream;

public interface LongTerminalOperationFactory extends BaseStreamTerminalOperationFactory {

TerminalOperation<LongStream, Void> createForEach(LongConsumer action);

TerminalOperation<LongStream, Void> createForEachOrdered(LongConsumer action);

TerminalOperation<LongStream, long[]> acquireToArray();

TerminalOperation<LongStream, Long> createReduce(long identity, LongBinaryOperator op);

TerminalOperation<LongStream, OptionalLong> createReduce(LongBinaryOperator op);

<R> TerminalOperation<LongStream, R> createCollect(Supplier<R> supplier,
ObjLongConsumer<R> accumulator,
BiConsumer<R, R> combiner);

TerminalOperation<LongStream, Long> acquireSum();

TerminalOperation<LongStream, OptionalLong> acquireMin();

TerminalOperation<LongStream, OptionalLong> acquireMax();

TerminalOperation<LongStream, Long> acquireCount();


TerminalOperation<LongStream, OptionalDouble> acquireAverage();

TerminalOperation<LongStream, LongSummaryStatistics> acquireSummaryStatistics();


TerminalOperation<LongStream, Boolean> createAnyMatch(LongPredicate predicate);

TerminalOperation<LongStream, Boolean> createAllMatch(LongPredicate predicate);

TerminalOperation<LongStream, Boolean> createNoneMatch(LongPredicate predicate);

TerminalOperation<LongStream, OptionalLong> acquireFindFirst();

TerminalOperation<LongStream, OptionalLong> acquireFindAny();

@SuppressWarnings("unchecked")
@Override
TerminalOperation<LongStream, PrimitiveIterator.OfLong> acquireIterator();

@SuppressWarnings("unchecked")
@Override
TerminalOperation<LongStream, Spliterator.OfLong> acquireSpliterator();

}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void testReduce() {

@Test
void collect() {
testTerminal(s -> s.collect(AtomicLong::new, (al, d) -> al.addAndGet((long) d), (a, b) -> a.addAndGet((long) b.get())), (a, b) -> a.get() == b.get());
testTerminal(s -> s.collect(AtomicLong::new, (al, d) -> al.addAndGet((long) d), (a, b) -> a.addAndGet(b.get())), (a, b) -> a.get() == b.get());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected Stream<Integer> initialStream() {

@Override
protected Stream<Integer> autoClosingStream(Stream<Integer> stream, boolean allowStreamIteratorAndSpliterator) {
return new AutoClosingStream(stream, allowStreamIteratorAndSpliterator);
return new AutoClosingStream<>(stream, allowStreamIteratorAndSpliterator);
}

@Override
Expand Down
Loading

0 comments on commit 1dfef51

Please sign in to comment.