[#4932] Revert
This commit is contained in:
parent
c8641be3c4
commit
3c42726975
@ -399,22 +399,6 @@ public interface Cursor<R extends Record> extends Iterable<R> , AutoCloseable {
|
||||
|
||||
/**
|
||||
* Turn this <code>Cursor</code> into a {@link Stream}.
|
||||
* <p>
|
||||
* The resulting stream is auto-closing upon:
|
||||
* <ul>
|
||||
* <li>Complete consumption</li>
|
||||
* <li>Any exception that is thrown by a stream sink</li>
|
||||
* <li>Any exception that is thrown by the underlying {@link ResultSet}, or
|
||||
* jOOQ</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* Clients who extract {@link Stream#iterator()} or
|
||||
* {@link Stream#spliterator()} cannot rely on this auto-closing behaviour
|
||||
* in the event of:
|
||||
* <ul>
|
||||
* <li>Incomplete consumption</li>
|
||||
* <li>Exceptions (which result in incomplete consumption)</li>
|
||||
* </ul>
|
||||
*
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
*/
|
||||
|
||||
@ -2423,22 +2423,6 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* <p>
|
||||
* Use {@link #fetch(ResultSet)}, to load the entire <code>ResultSet</code>
|
||||
* into a jOOQ <code>Result</code> at once.
|
||||
* <p>
|
||||
* The resulting stream is auto-closing upon:
|
||||
* <ul>
|
||||
* <li>Complete consumption</li>
|
||||
* <li>Any exception that is thrown by a stream sink</li>
|
||||
* <li>Any exception that is thrown by the underlying {@link ResultSet}, or
|
||||
* jOOQ</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* Clients who extract {@link Stream#iterator()} or
|
||||
* {@link Stream#spliterator()} cannot rely on this auto-closing behaviour
|
||||
* in the event of:
|
||||
* <ul>
|
||||
* <li>Incomplete consumption</li>
|
||||
* <li>Exceptions (which result in incomplete consumption)</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param rs The JDBC ResultSet to fetch data from
|
||||
* @return The resulting stream
|
||||
@ -2454,23 +2438,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* into a jOOQ <code>Result</code> at once.
|
||||
* <p>
|
||||
* The additional <code>fields</code> argument is used by jOOQ to coerce
|
||||
* field names and data types to the desired output.
|
||||
* <p>
|
||||
* The resulting stream is auto-closing upon:
|
||||
* <ul>
|
||||
* <li>Complete consumption</li>
|
||||
* <li>Any exception that is thrown by a stream sink</li>
|
||||
* <li>Any exception that is thrown by the underlying {@link ResultSet}, or
|
||||
* jOOQ</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* Clients who extract {@link Stream#iterator()} or
|
||||
* {@link Stream#spliterator()} cannot rely on this auto-closing behaviour
|
||||
* in the event of:
|
||||
* <ul>
|
||||
* <li>Incomplete consumption</li>
|
||||
* <li>Exceptions (which result in incomplete consumption)</li>
|
||||
* </ul>
|
||||
* field names and data types to the desired output
|
||||
*
|
||||
* @param rs The JDBC ResultSet to fetch data from
|
||||
* @param fields The fields to use in the desired output
|
||||
@ -2487,23 +2455,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* into a jOOQ <code>Result</code> at once.
|
||||
* <p>
|
||||
* The additional <code>types</code> argument is used by jOOQ to coerce data
|
||||
* types to the desired output.
|
||||
* <p>
|
||||
* The resulting stream is auto-closing upon:
|
||||
* <ul>
|
||||
* <li>Complete consumption</li>
|
||||
* <li>Any exception that is thrown by a stream sink</li>
|
||||
* <li>Any exception that is thrown by the underlying {@link ResultSet}, or
|
||||
* jOOQ</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* Clients who extract {@link Stream#iterator()} or
|
||||
* {@link Stream#spliterator()} cannot rely on this auto-closing behaviour
|
||||
* in the event of:
|
||||
* <ul>
|
||||
* <li>Incomplete consumption</li>
|
||||
* <li>Exceptions (which result in incomplete consumption)</li>
|
||||
* </ul>
|
||||
* types to the desired output
|
||||
*
|
||||
* @param rs The JDBC ResultSet to fetch data from
|
||||
* @param types The data types to use in the desired output
|
||||
@ -2520,23 +2472,7 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
* into a jOOQ <code>Result</code> at once.
|
||||
* <p>
|
||||
* The additional <code>types</code> argument is used by jOOQ to coerce data
|
||||
* types to the desired output.
|
||||
* <p>
|
||||
* The resulting stream is auto-closing upon:
|
||||
* <ul>
|
||||
* <li>Complete consumption</li>
|
||||
* <li>Any exception that is thrown by a stream sink</li>
|
||||
* <li>Any exception that is thrown by the underlying {@link ResultSet}, or
|
||||
* jOOQ</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* Clients who extract {@link Stream#iterator()} or
|
||||
* {@link Stream#spliterator()} cannot rely on this auto-closing behaviour
|
||||
* in the event of:
|
||||
* <ul>
|
||||
* <li>Incomplete consumption</li>
|
||||
* <li>Exceptions (which result in incomplete consumption)</li>
|
||||
* </ul>
|
||||
* types to the desired output
|
||||
*
|
||||
* @param rs The JDBC ResultSet to fetch data from
|
||||
* @param types The data types to use in the desired output
|
||||
|
||||
@ -53,6 +53,8 @@ import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.jooq.conf.Settings;
|
||||
import org.jooq.exception.DataAccessException;
|
||||
import org.jooq.exception.DataTypeException;
|
||||
@ -147,22 +149,6 @@ public interface ResultQuery<R extends Record> extends Query, Iterable<R> {
|
||||
/**
|
||||
* Stream this query.
|
||||
* <p>
|
||||
* The resulting stream is auto-closing upon:
|
||||
* <ul>
|
||||
* <li>Complete consumption</li>
|
||||
* <li>Any exception that is thrown by a stream sink</li>
|
||||
* <li>Any exception that is thrown by the underlying {@link ResultSet}, or
|
||||
* jOOQ</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* Clients who extract {@link Stream#iterator()} or
|
||||
* {@link Stream#spliterator()} cannot rely on this auto-closing behaviour
|
||||
* in the event of:
|
||||
* <ul>
|
||||
* <li>Incomplete consumption</li>
|
||||
* <li>Exceptions (which result in incomplete consumption)</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* This is just a synonym for {@link #stream()}.
|
||||
*
|
||||
* @return The result.
|
||||
@ -174,21 +160,20 @@ public interface ResultQuery<R extends Record> extends Query, Iterable<R> {
|
||||
/**
|
||||
* Stream this query.
|
||||
* <p>
|
||||
* The resulting stream is auto-closing upon:
|
||||
* <ul>
|
||||
* <li>Complete consumption</li>
|
||||
* <li>Any exception that is thrown by a stream sink</li>
|
||||
* <li>Any exception that is thrown by the underlying {@link ResultSet}, or
|
||||
* jOOQ</li>
|
||||
* </ul>
|
||||
* This is essentially the same as {@link #fetchLazy()} but instead of
|
||||
* returning a {@link Cursor}, a Java 8 {@link Stream} is returned. Clients
|
||||
* should ensure the {@link Stream} is properly closed, e.g. in a
|
||||
* try-with-resources statement:
|
||||
* <p>
|
||||
* Clients who extract {@link Stream#iterator()} or
|
||||
* {@link Stream#spliterator()} cannot rely on this auto-closing behaviour
|
||||
* in the event of:
|
||||
* <ul>
|
||||
* <li>Incomplete consumption</li>
|
||||
* <li>Exceptions (which result in incomplete consumption)</li>
|
||||
* </ul>
|
||||
* <code><pre>
|
||||
* try (Stream<R> stream = query.stream()) {
|
||||
* // Do things with stream
|
||||
* }
|
||||
* </pre></code>
|
||||
* <p>
|
||||
* If users prefer more fluent style streaming of queries, {@link ResultSet}
|
||||
* can be registered and closed via {@link ExecuteListener}, or via "smart"
|
||||
* third-party {@link DataSource}s.
|
||||
*
|
||||
* @return The result.
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
|
||||
@ -1,151 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2009-2016, Data Geekery GmbH (http://www.datageekery.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.BaseStream;
|
||||
import java.util.stream.DoubleStream;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.LongStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* A {@link Stream} wrapper that auto-closes itself:
|
||||
* <ul>
|
||||
* <li>Upon failure</li>
|
||||
* <li>Upon a terminal operation</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
abstract class AutoClosingBaseStream<T, S extends BaseStream<T, S>, U extends AutoClosingBaseStream<T, S, U>> implements BaseStream<T, S> {
|
||||
|
||||
final S delegate;
|
||||
final Consumer<Optional<Throwable>> onComplete;
|
||||
|
||||
AutoClosingBaseStream(S delegate, Consumer<Optional<Throwable>> onComplete) {
|
||||
this.delegate = delegate;
|
||||
this.onComplete = onComplete;
|
||||
}
|
||||
|
||||
abstract S delegateOf(S newDelegate);
|
||||
|
||||
final <X> Stream<X> delegate(Stream<X> newDelegate) {
|
||||
return new AutoClosingStream<>(newDelegate, onComplete);
|
||||
}
|
||||
|
||||
final IntStream delegate(IntStream newDelegate) {
|
||||
return new AutoClosingIntStream(newDelegate, onComplete);
|
||||
}
|
||||
|
||||
final LongStream delegate(LongStream newDelegate) {
|
||||
return new AutoClosingLongStream(newDelegate, onComplete);
|
||||
}
|
||||
|
||||
final DoubleStream delegate(DoubleStream newDelegate) {
|
||||
return new AutoClosingDoubleStream(newDelegate, onComplete);
|
||||
}
|
||||
|
||||
final void terminalOp(Runnable runnable) {
|
||||
terminalOp(() -> {
|
||||
runnable.run();
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
final <R1> R1 terminalOp(Supplier<R1> supplier) {
|
||||
R1 result = null;
|
||||
|
||||
try {
|
||||
result = supplier.get();
|
||||
close();
|
||||
}
|
||||
catch (Throwable e) {
|
||||
close();
|
||||
throw e;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// These methods are not affected by the auto-closing semantics
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final boolean isParallel() {
|
||||
return delegate.isParallel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void close() {
|
||||
delegate.close();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// These methods forward to delegate stream, and wrap afresh
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final S sequential() {
|
||||
return delegateOf(delegate.sequential());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final S parallel() {
|
||||
return delegateOf(delegate.parallel());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final S unordered() {
|
||||
return delegateOf(delegate.unordered());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final S onClose(Runnable closeHandler) {
|
||||
return delegateOf(delegate.onClose(closeHandler));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,253 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2009-2016, Data Geekery GmbH (http://www.datageekery.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
import java.util.DoubleSummaryStatistics;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalDouble;
|
||||
import java.util.PrimitiveIterator;
|
||||
import java.util.Spliterator;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.DoubleBinaryOperator;
|
||||
import java.util.function.DoubleConsumer;
|
||||
import java.util.function.DoubleFunction;
|
||||
import java.util.function.DoublePredicate;
|
||||
import java.util.function.DoubleToIntFunction;
|
||||
import java.util.function.DoubleToLongFunction;
|
||||
import java.util.function.DoubleUnaryOperator;
|
||||
import java.util.function.ObjDoubleConsumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.DoubleStream;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.LongStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* A {@link DoubleStream} wrapper that auto-closes itself:
|
||||
* <ul>
|
||||
* <li>Upon failure</li>
|
||||
* <li>Upon a terminal operation</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
class AutoClosingDoubleStream extends AutoClosingBaseStream<Double, DoubleStream, AutoClosingDoubleStream> implements DoubleStream {
|
||||
|
||||
AutoClosingDoubleStream(DoubleStream delegate, Consumer<Optional<Throwable>> onComplete) {
|
||||
super(delegate, onComplete);
|
||||
}
|
||||
|
||||
@Override
|
||||
final DoubleStream delegateOf(DoubleStream newDelegate) {
|
||||
return delegate(newDelegate);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// These methods break the auto-closing semantics
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final PrimitiveIterator.OfDouble iterator() {
|
||||
return delegate.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Spliterator.OfDouble spliterator() {
|
||||
return delegate.spliterator();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// These methods forward to delegate stream, and wrap afresh
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final DoubleStream filter(DoublePredicate predicate) {
|
||||
return delegate(delegate.filter(predicate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DoubleStream map(DoubleUnaryOperator mapper) {
|
||||
return delegate(delegate.map(mapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <U> Stream<U> mapToObj(DoubleFunction<? extends U> mapper) {
|
||||
return delegate(delegate.mapToObj(mapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IntStream mapToInt(DoubleToIntFunction mapper) {
|
||||
return delegate(delegate.mapToInt(mapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final LongStream mapToLong(DoubleToLongFunction mapper) {
|
||||
return delegate(delegate.mapToLong(mapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DoubleStream flatMap(DoubleFunction<? extends DoubleStream> mapper) {
|
||||
return delegate(delegate.flatMap(mapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DoubleStream distinct() {
|
||||
return delegate(delegate.distinct());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DoubleStream sorted() {
|
||||
return delegate(delegate.sorted());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DoubleStream peek(DoubleConsumer action) {
|
||||
return delegate.peek(action);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DoubleStream limit(long maxSize) {
|
||||
return delegate(delegate.limit(maxSize));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DoubleStream skip(long n) {
|
||||
return delegate(delegate.skip(n));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Stream<Double> boxed() {
|
||||
return delegate(delegate.boxed());
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// These methods implement terminal op semantics, and implement auto-closing
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final void forEach(DoubleConsumer action) {
|
||||
terminalOp(() -> delegate.forEach(action));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void forEachOrdered(DoubleConsumer action) {
|
||||
terminalOp(() -> delegate.forEachOrdered(action));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final double[] toArray() {
|
||||
return terminalOp(() -> delegate.toArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final double reduce(double identity, DoubleBinaryOperator op) {
|
||||
return terminalOp(() -> delegate.reduce(identity, op));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final OptionalDouble reduce(DoubleBinaryOperator op) {
|
||||
return terminalOp(() -> delegate.reduce(op));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <R> R collect(Supplier<R> supplier, ObjDoubleConsumer<R> accumulator, BiConsumer<R, R> combiner) {
|
||||
return terminalOp(() -> delegate.collect(supplier, accumulator, combiner));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final double sum() {
|
||||
return terminalOp(() -> delegate.sum());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final OptionalDouble min() {
|
||||
return terminalOp(() -> delegate.min());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final OptionalDouble max() {
|
||||
return terminalOp(() -> delegate.max());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final long count() {
|
||||
return terminalOp(() -> delegate.count());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final OptionalDouble average() {
|
||||
return terminalOp(() -> delegate.average());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DoubleSummaryStatistics summaryStatistics() {
|
||||
return terminalOp(() -> delegate.summaryStatistics());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean anyMatch(DoublePredicate predicate) {
|
||||
return terminalOp(() -> delegate.anyMatch(predicate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean allMatch(DoublePredicate predicate) {
|
||||
return terminalOp(() -> delegate.allMatch(predicate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean noneMatch(DoublePredicate predicate) {
|
||||
return terminalOp(() -> delegate.noneMatch(predicate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final OptionalDouble findFirst() {
|
||||
return terminalOp(() -> delegate.findFirst());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final OptionalDouble findAny() {
|
||||
return terminalOp(() -> delegate.findAny());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,264 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2009-2016, Data Geekery GmbH (http://www.datageekery.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
import java.util.IntSummaryStatistics;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalDouble;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.PrimitiveIterator;
|
||||
import java.util.Spliterator;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.IntBinaryOperator;
|
||||
import java.util.function.IntConsumer;
|
||||
import java.util.function.IntFunction;
|
||||
import java.util.function.IntPredicate;
|
||||
import java.util.function.IntToDoubleFunction;
|
||||
import java.util.function.IntToLongFunction;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
import java.util.function.ObjIntConsumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.DoubleStream;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.LongStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* An {@link IntStream} wrapper that auto-closes itself:
|
||||
* <ul>
|
||||
* <li>Upon failure</li>
|
||||
* <li>Upon a terminal operation</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
class AutoClosingIntStream extends AutoClosingBaseStream<Integer, IntStream, AutoClosingIntStream> implements IntStream {
|
||||
|
||||
AutoClosingIntStream(IntStream delegate, Consumer<Optional<Throwable>> onComplete) {
|
||||
super(delegate, onComplete);
|
||||
}
|
||||
|
||||
@Override
|
||||
final IntStream delegateOf(IntStream newDelegate) {
|
||||
return delegate(newDelegate);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// These methods break the auto-closing semantics
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final PrimitiveIterator.OfInt iterator() {
|
||||
return delegate.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Spliterator.OfInt spliterator() {
|
||||
return delegate.spliterator();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// These methods forward to delegate stream, and wrap afresh
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final IntStream filter(IntPredicate predicate) {
|
||||
return delegate(delegate.filter(predicate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IntStream map(IntUnaryOperator mapper) {
|
||||
return delegate(delegate.map(mapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <U> Stream<U> mapToObj(IntFunction<? extends U> mapper) {
|
||||
return delegate(delegate.mapToObj(mapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final LongStream mapToLong(IntToLongFunction mapper) {
|
||||
return delegate(delegate.mapToLong(mapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DoubleStream mapToDouble(IntToDoubleFunction mapper) {
|
||||
return delegate(delegate.mapToDouble(mapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IntStream flatMap(IntFunction<? extends IntStream> mapper) {
|
||||
return delegate(delegate.flatMap(mapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IntStream distinct() {
|
||||
return delegate(delegate.distinct());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IntStream sorted() {
|
||||
return delegate(delegate.sorted());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IntStream peek(IntConsumer action) {
|
||||
return delegate.peek(action);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IntStream limit(long maxSize) {
|
||||
return delegate(delegate.limit(maxSize));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IntStream skip(long n) {
|
||||
return delegate(delegate.skip(n));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final LongStream asLongStream() {
|
||||
return delegate(delegate.asLongStream());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DoubleStream asDoubleStream() {
|
||||
return delegate(delegate.asDoubleStream());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Stream<Integer> boxed() {
|
||||
return delegate(delegate.boxed());
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// These methods implement terminal op semantics, and implement auto-closing
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final void forEach(IntConsumer action) {
|
||||
terminalOp(() -> delegate.forEach(action));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void forEachOrdered(IntConsumer action) {
|
||||
terminalOp(() -> delegate.forEachOrdered(action));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int[] toArray() {
|
||||
return terminalOp(() -> delegate.toArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int reduce(int identity, IntBinaryOperator op) {
|
||||
return terminalOp(() -> delegate.reduce(identity, op));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final OptionalInt reduce(IntBinaryOperator op) {
|
||||
return terminalOp(() -> delegate.reduce(op));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <R> R collect(Supplier<R> supplier, ObjIntConsumer<R> accumulator, BiConsumer<R, R> combiner) {
|
||||
return terminalOp(() -> delegate.collect(supplier, accumulator, combiner));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int sum() {
|
||||
return terminalOp(() -> delegate.sum());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final OptionalInt min() {
|
||||
return terminalOp(() -> delegate.min());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final OptionalInt max() {
|
||||
return terminalOp(() -> delegate.max());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final long count() {
|
||||
return terminalOp(() -> delegate.count());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final OptionalDouble average() {
|
||||
return terminalOp(() -> delegate.average());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IntSummaryStatistics summaryStatistics() {
|
||||
return terminalOp(() -> delegate.summaryStatistics());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean anyMatch(IntPredicate predicate) {
|
||||
return terminalOp(() -> delegate.anyMatch(predicate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean allMatch(IntPredicate predicate) {
|
||||
return terminalOp(() -> delegate.allMatch(predicate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean noneMatch(IntPredicate predicate) {
|
||||
return terminalOp(() -> delegate.noneMatch(predicate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final OptionalInt findFirst() {
|
||||
return terminalOp(() -> delegate.findFirst());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final OptionalInt findAny() {
|
||||
return terminalOp(() -> delegate.findAny());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,259 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2009-2016, Data Geekery GmbH (http://www.datageekery.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
import java.util.LongSummaryStatistics;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalDouble;
|
||||
import java.util.OptionalLong;
|
||||
import java.util.PrimitiveIterator;
|
||||
import java.util.Spliterator;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.LongBinaryOperator;
|
||||
import java.util.function.LongConsumer;
|
||||
import java.util.function.LongFunction;
|
||||
import java.util.function.LongPredicate;
|
||||
import java.util.function.LongToDoubleFunction;
|
||||
import java.util.function.LongToIntFunction;
|
||||
import java.util.function.LongUnaryOperator;
|
||||
import java.util.function.ObjLongConsumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.DoubleStream;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.LongStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* A {@link LongStream} wrapper that auto-closes itself:
|
||||
* <ul>
|
||||
* <li>Upon failure</li>
|
||||
* <li>Upon a terminal operation</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
class AutoClosingLongStream extends AutoClosingBaseStream<Long, LongStream, AutoClosingLongStream> implements LongStream {
|
||||
|
||||
AutoClosingLongStream(LongStream delegate, Consumer<Optional<Throwable>> onComplete) {
|
||||
super(delegate, onComplete);
|
||||
}
|
||||
|
||||
@Override
|
||||
final LongStream delegateOf(LongStream newDelegate) {
|
||||
return delegate(newDelegate);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// These methods break the auto-closing semantics
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final PrimitiveIterator.OfLong iterator() {
|
||||
return delegate.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Spliterator.OfLong spliterator() {
|
||||
return delegate.spliterator();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// These methods forward to delegate stream, and wrap afresh
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final LongStream filter(LongPredicate predicate) {
|
||||
return delegate(delegate.filter(predicate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final LongStream map(LongUnaryOperator mapper) {
|
||||
return delegate(delegate.map(mapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <U> Stream<U> mapToObj(LongFunction<? extends U> mapper) {
|
||||
return delegate(delegate.mapToObj(mapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IntStream mapToInt(LongToIntFunction mapper) {
|
||||
return delegate(delegate.mapToInt(mapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DoubleStream mapToDouble(LongToDoubleFunction mapper) {
|
||||
return delegate(delegate.mapToDouble(mapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final LongStream flatMap(LongFunction<? extends LongStream> mapper) {
|
||||
return delegate(delegate.flatMap(mapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final LongStream distinct() {
|
||||
return delegate(delegate.distinct());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final LongStream sorted() {
|
||||
return delegate(delegate.sorted());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final LongStream peek(LongConsumer action) {
|
||||
return delegate.peek(action);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final LongStream limit(long maxSize) {
|
||||
return delegate(delegate.limit(maxSize));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final LongStream skip(long n) {
|
||||
return delegate(delegate.skip(n));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DoubleStream asDoubleStream() {
|
||||
return delegate(delegate.asDoubleStream());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Stream<Long> boxed() {
|
||||
return delegate(delegate.boxed());
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// These methods implement terminal op semantics, and implement auto-closing
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final void forEach(LongConsumer action) {
|
||||
terminalOp(() -> delegate.forEach(action));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void forEachOrdered(LongConsumer action) {
|
||||
terminalOp(() -> delegate.forEachOrdered(action));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final long[] toArray() {
|
||||
return terminalOp(() -> delegate.toArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final long reduce(long identity, LongBinaryOperator op) {
|
||||
return terminalOp(() -> delegate.reduce(identity, op));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final OptionalLong reduce(LongBinaryOperator op) {
|
||||
return terminalOp(() -> delegate.reduce(op));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <R> R collect(Supplier<R> supplier, ObjLongConsumer<R> accumulator, BiConsumer<R, R> combiner) {
|
||||
return terminalOp(() -> delegate.collect(supplier, accumulator, combiner));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final long sum() {
|
||||
return terminalOp(() -> delegate.sum());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final OptionalLong min() {
|
||||
return terminalOp(() -> delegate.min());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final OptionalLong max() {
|
||||
return terminalOp(() -> delegate.max());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final long count() {
|
||||
return terminalOp(() -> delegate.count());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final OptionalDouble average() {
|
||||
return terminalOp(() -> delegate.average());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final LongSummaryStatistics summaryStatistics() {
|
||||
return terminalOp(() -> delegate.summaryStatistics());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean anyMatch(LongPredicate predicate) {
|
||||
return terminalOp(() -> delegate.anyMatch(predicate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean allMatch(LongPredicate predicate) {
|
||||
return terminalOp(() -> delegate.allMatch(predicate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean noneMatch(LongPredicate predicate) {
|
||||
return terminalOp(() -> delegate.noneMatch(predicate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final OptionalLong findFirst() {
|
||||
return terminalOp(() -> delegate.findFirst());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final OptionalLong findAny() {
|
||||
return terminalOp(() -> delegate.findAny());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,268 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2009-2016, Data Geekery GmbH (http://www.datageekery.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.Optional;
|
||||
import java.util.Spliterator;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.BinaryOperator;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.IntFunction;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.ToDoubleFunction;
|
||||
import java.util.function.ToIntFunction;
|
||||
import java.util.function.ToLongFunction;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.DoubleStream;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.LongStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* A {@link Stream} wrapper that auto-closes itself:
|
||||
* <ul>
|
||||
* <li>Upon failure</li>
|
||||
* <li>Upon a terminal operation</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
class AutoClosingStream<T> extends AutoClosingBaseStream<T, Stream<T>, AutoClosingStream<T>> implements Stream<T> {
|
||||
|
||||
AutoClosingStream(Stream<T> delegate, Consumer<Optional<Throwable>> onComplete) {
|
||||
super(delegate, onComplete);
|
||||
}
|
||||
|
||||
@Override
|
||||
final Stream<T> delegateOf(Stream<T> newDelegate) {
|
||||
return delegate(newDelegate);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// These methods break the auto-closing semantics
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Iterator<T> iterator() {
|
||||
return delegate.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Spliterator<T> spliterator() {
|
||||
return delegate.spliterator();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// These methods forward to delegate stream, and wrap afresh
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final Stream<T> filter(Predicate<? super T> predicate) {
|
||||
return delegate(delegate.filter(predicate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <R> Stream<R> map(Function<? super T, ? extends R> mapper) {
|
||||
return delegate(delegate.map(mapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IntStream mapToInt(ToIntFunction<? super T> mapper) {
|
||||
return delegate(delegate.mapToInt(mapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final LongStream mapToLong(ToLongFunction<? super T> mapper) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DoubleStream mapToDouble(ToDoubleFunction<? super T> mapper) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <R> Stream<R> flatMap(Function<? super T, ? extends Stream<? extends R>> mapper) {
|
||||
return delegate(delegate.flatMap(mapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IntStream flatMapToInt(Function<? super T, ? extends IntStream> mapper) {
|
||||
return delegate(delegate.flatMapToInt(mapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final LongStream flatMapToLong(Function<? super T, ? extends LongStream> mapper) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final DoubleStream flatMapToDouble(Function<? super T, ? extends DoubleStream> mapper) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Stream<T> distinct() {
|
||||
return delegate(delegate.distinct());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Stream<T> sorted() {
|
||||
return delegate(delegate.sorted());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Stream<T> sorted(Comparator<? super T> comparator) {
|
||||
return delegate(delegate.sorted(comparator));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Stream<T> peek(Consumer<? super T> action) {
|
||||
return delegate(delegate.peek(action));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Stream<T> limit(long maxSize) {
|
||||
return delegate(delegate.limit(maxSize));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Stream<T> skip(long n) {
|
||||
return delegate(delegate.skip(n));
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// These methods implement terminal op semantics, and implement auto-closing
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final void forEach(Consumer<? super T> action) {
|
||||
terminalOp(() -> delegate.forEach(action));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void forEachOrdered(Consumer<? super T> action) {
|
||||
terminalOp(() -> delegate.forEachOrdered(action));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Object[] toArray() {
|
||||
return terminalOp(() -> delegate.toArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <A> A[] toArray(IntFunction<A[]> generator) {
|
||||
return terminalOp(() -> delegate.toArray(generator));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final T reduce(T identity, BinaryOperator<T> accumulator) {
|
||||
return terminalOp(() -> delegate.reduce(identity, accumulator));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Optional<T> reduce(BinaryOperator<T> accumulator) {
|
||||
return terminalOp(() -> delegate.reduce(accumulator));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <U> U reduce(U identity, BiFunction<U, ? super T, U> accumulator, BinaryOperator<U> combiner) {
|
||||
return terminalOp(() -> delegate.reduce(identity, accumulator, combiner));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <R> R collect(Supplier<R> supplier, BiConsumer<R, ? super T> accumulator, BiConsumer<R, R> combiner) {
|
||||
return terminalOp(() -> delegate.collect(supplier, accumulator, combiner));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <R, A> R collect(Collector<? super T, A, R> collector) {
|
||||
return terminalOp(() -> delegate.collect(collector));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Optional<T> min(Comparator<? super T> comparator) {
|
||||
return terminalOp(() -> delegate.min(comparator));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Optional<T> max(Comparator<? super T> comparator) {
|
||||
return terminalOp(() -> delegate.max(comparator));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final long count() {
|
||||
return terminalOp(() -> delegate.count());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean anyMatch(Predicate<? super T> predicate) {
|
||||
return terminalOp(() -> delegate.anyMatch(predicate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean allMatch(Predicate<? super T> predicate) {
|
||||
return terminalOp(() -> delegate.allMatch(predicate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean noneMatch(Predicate<? super T> predicate) {
|
||||
return terminalOp(() -> delegate.noneMatch(predicate));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Optional<T> findFirst() {
|
||||
return terminalOp(() -> delegate.findFirst());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Optional<T> findAny() {
|
||||
return terminalOp(() -> delegate.findAny());
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,20 +261,14 @@ class CursorImpl<R extends Record> implements Cursor<R> {
|
||||
|
||||
@Override
|
||||
public final Stream<R> stream() throws DataAccessException {
|
||||
return new AutoClosingStream<R>(
|
||||
StreamSupport.stream(
|
||||
Spliterators.spliterator(
|
||||
iterator(),
|
||||
0,
|
||||
Spliterator.ORDERED | Spliterator.NONNULL
|
||||
),
|
||||
false
|
||||
).onClose(() -> close()),
|
||||
o -> {
|
||||
close();
|
||||
o.ifPresent(e -> Utils.sneakyThrow(e));
|
||||
}
|
||||
);
|
||||
return StreamSupport.stream(
|
||||
Spliterators.spliterator(
|
||||
iterator(),
|
||||
0,
|
||||
Spliterator.ORDERED | Spliterator.NONNULL
|
||||
),
|
||||
false
|
||||
).onClose(() -> close());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2935,19 +2935,4 @@ final class Utils {
|
||||
ctx.keyword(typeName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sneaky throw any type of Throwable.
|
||||
*/
|
||||
static void sneakyThrow(Throwable throwable) {
|
||||
Utils.<RuntimeException>sneakyThrow0(throwable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sneaky throw any type of Throwable.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
static <E extends Throwable> void sneakyThrow0(Throwable throwable) throws E {
|
||||
throw (E) throwable;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user