• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle in the LICENSE file that accompanied this code.
10  *
11  * This code is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * version 2 for more details (a copy is included in the LICENSE file that
15  * accompanied this code).
16  *
17  * You should have received a copy of the GNU General Public License version
18  * 2 along with this work; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 package org.openjdk.testlib.java.util.stream;
26 
27 import java.lang.reflect.Method;
28 import java.lang.reflect.Modifier;
29 import java.util.Comparator;
30 import java.util.DoubleSummaryStatistics;
31 import java.util.IntSummaryStatistics;
32 import java.util.Iterator;
33 import java.util.LongSummaryStatistics;
34 import java.util.Optional;
35 import java.util.OptionalDouble;
36 import java.util.OptionalInt;
37 import java.util.OptionalLong;
38 import java.util.PrimitiveIterator;
39 import java.util.Set;
40 import java.util.Spliterator;
41 import java.util.function.BiConsumer;
42 import java.util.function.BiFunction;
43 import java.util.function.BinaryOperator;
44 import java.util.function.Consumer;
45 import java.util.function.DoubleBinaryOperator;
46 import java.util.function.DoubleConsumer;
47 import java.util.function.DoubleFunction;
48 import java.util.function.DoublePredicate;
49 import java.util.function.DoubleToIntFunction;
50 import java.util.function.DoubleToLongFunction;
51 import java.util.function.DoubleUnaryOperator;
52 import java.util.function.Function;
53 import java.util.function.IntBinaryOperator;
54 import java.util.function.IntConsumer;
55 import java.util.function.IntFunction;
56 import java.util.function.IntPredicate;
57 import java.util.function.IntToDoubleFunction;
58 import java.util.function.IntToLongFunction;
59 import java.util.function.IntUnaryOperator;
60 import java.util.function.LongBinaryOperator;
61 import java.util.function.LongConsumer;
62 import java.util.function.LongFunction;
63 import java.util.function.LongPredicate;
64 import java.util.function.LongToDoubleFunction;
65 import java.util.function.LongToIntFunction;
66 import java.util.function.LongUnaryOperator;
67 import java.util.function.ObjDoubleConsumer;
68 import java.util.function.ObjIntConsumer;
69 import java.util.function.ObjLongConsumer;
70 import java.util.function.Predicate;
71 import java.util.function.Supplier;
72 import java.util.function.ToDoubleFunction;
73 
74 import java.util.function.ToIntFunction;
75 import java.util.function.ToLongFunction;
76 
77 import java.util.stream.*;
78 
79 import static java.util.stream.Collectors.*;
80 
81 public final class DefaultMethodStreams {
82 
83     static {
84         // Verify that default methods are not overridden
85         verify(DefaultMethodRefStream.class);
86         verify(DefaultMethodIntStream.class);
87         verify(DefaultMethodLongStream.class);
88         verify(DefaultMethodDoubleStream.class);
89     }
90 
verify(Class<?> del)91     static void verify(Class<?> del) {
92         // Find the stream interface
93         Class<?> s = Stream.of(del.getInterfaces())
94                 .filter(c -> BaseStream.class.isAssignableFrom(c))
95                 .findFirst().get();
96 
97         // Get all default methods on the stream class
98         Set<String> dms = Stream.of(s.getMethods())
99                 .filter(m -> !Modifier.isStatic(m.getModifiers()))
100                 .filter(m -> !m.isBridge())
101                 .filter(Method::isDefault)
102                 .map(Method::getName)
103                 .collect(toSet());
104 
105         // Get all methods on the delegating class
106         Set<String> ims = Stream.of(del.getMethods())
107                 .filter(m -> !Modifier.isStatic(m.getModifiers()))
108                 .filter(m -> m.getDeclaringClass() == del)
109                 .map(Method::getName)
110                 .collect(toSet());
111 
112         if (ims.stream().anyMatch(dms::contains)) {
113             throw new AssertionError(String.format("%s overrides default methods of %s\n", del, s));
114         }
115     }
116 
117     /**
118      * Creates a stream that for the next operation either delegates to
119      * a default method on {@link Stream}, if present for that operation,
120      * otherwise delegates to an underlying stream.
121      *
122      * @param s the underlying stream to be delegated to for non-default
123      * methods.
124      * @param <T> the type of the stream elements
125      * @return the delegating stream
126      */
delegateTo(Stream<T> s)127     public static <T> Stream<T> delegateTo(Stream<T> s) {
128         return new DefaultMethodRefStream<>(s);
129     }
130 
131     /**
132      * Creates a stream that for the next operation either delegates to
133      * a default method on {@link IntStream}, if present for that operation,
134      * otherwise delegates to an underlying stream.
135      *
136      * @param s the underlying stream to be delegated to for non-default
137      * methods.
138      * @return the delegating stream
139      */
delegateTo(IntStream s)140     public static IntStream delegateTo(IntStream s) {
141         return new DefaultMethodIntStream(s);
142     }
143 
144     /**
145      * Creates a stream that for the next operation either delegates to
146      * a default method on {@link LongStream}, if present for that operation,
147      * otherwise delegates to an underlying stream.
148      *
149      * @param s the underlying stream to be delegated to for non-default
150      * methods.
151      * @return the delegating stream
152      */
delegateTo(LongStream s)153     public static LongStream delegateTo(LongStream s) {
154         return new DefaultMethodLongStream(s);
155     }
156 
157     /**
158      * Creates a stream that for the next operation either delegates to
159      * a default method on {@link DoubleStream}, if present for that operation,
160      * otherwise delegates to an underlying stream.
161      *
162      * @param s the underlying stream to be delegated to for non-default
163      * methods.
164      * @return the delegating stream
165      */
delegateTo(DoubleStream s)166     public static DoubleStream delegateTo(DoubleStream s) {
167         return new DefaultMethodDoubleStream(s);
168     }
169 
170     /**
171      * A stream that delegates the next operation to a default method, if
172      * present, or to the same operation of an underlying stream.
173      *
174      * @param <T> the type of the stream elements
175      */
176     static final class DefaultMethodRefStream<T> implements Stream<T> {
177         final Stream<T> s;
178 
DefaultMethodRefStream(Stream<T> s)179         DefaultMethodRefStream(Stream<T> s) {
180             this.s = s;
181         }
182 
183 
184         // Delegating non-default methods
185 
186         @Override
filter(Predicate<? super T> predicate)187         public Stream<T> filter(Predicate<? super T> predicate) {
188             return s.filter(predicate);
189         }
190 
191         @Override
map(Function<? super T, ? extends R> mapper)192         public <R> Stream<R> map(Function<? super T, ? extends R> mapper) {
193             return s.map(mapper);
194         }
195 
196         @Override
mapToInt(ToIntFunction<? super T> mapper)197         public IntStream mapToInt(ToIntFunction<? super T> mapper) {
198             return s.mapToInt(mapper);
199         }
200 
201         @Override
mapToLong(ToLongFunction<? super T> mapper)202         public LongStream mapToLong(ToLongFunction<? super T> mapper) {
203             return s.mapToLong(mapper);
204         }
205 
206         @Override
mapToDouble(ToDoubleFunction<? super T> mapper)207         public DoubleStream mapToDouble(ToDoubleFunction<? super T> mapper) {
208             return s.mapToDouble(mapper);
209         }
210 
211         @Override
flatMap(Function<? super T, ? extends Stream<? extends R>> mapper)212         public <R> Stream<R> flatMap(Function<? super T, ? extends Stream<? extends R>> mapper) {
213             return s.flatMap(mapper);
214         }
215 
216         @Override
flatMapToInt(Function<? super T, ? extends IntStream> mapper)217         public IntStream flatMapToInt(Function<? super T, ? extends IntStream> mapper) {
218             return s.flatMapToInt(mapper);
219         }
220 
221         @Override
flatMapToLong(Function<? super T, ? extends LongStream> mapper)222         public LongStream flatMapToLong(Function<? super T, ? extends LongStream> mapper) {
223             return s.flatMapToLong(mapper);
224         }
225 
226         @Override
flatMapToDouble(Function<? super T, ? extends DoubleStream> mapper)227         public DoubleStream flatMapToDouble(Function<? super T, ? extends DoubleStream> mapper) {
228             return s.flatMapToDouble(mapper);
229         }
230 
231         @Override
distinct()232         public Stream<T> distinct() {
233             return s.distinct();
234         }
235 
236         @Override
sorted()237         public Stream<T> sorted() {
238             return s.sorted();
239         }
240 
241         @Override
sorted(Comparator<? super T> comparator)242         public Stream<T> sorted(Comparator<? super T> comparator) {
243             return s.sorted(comparator);
244         }
245 
246         @Override
peek(Consumer<? super T> action)247         public Stream<T> peek(Consumer<? super T> action) {
248             return s.peek(action);
249         }
250 
251         @Override
limit(long maxSize)252         public Stream<T> limit(long maxSize) {
253             return s.limit(maxSize);
254         }
255 
256         @Override
skip(long n)257         public Stream<T> skip(long n) {
258             return s.skip(n);
259         }
260 
261         @Override
forEach(Consumer<? super T> action)262         public void forEach(Consumer<? super T> action) {
263             s.forEach(action);
264         }
265 
266         @Override
forEachOrdered(Consumer<? super T> action)267         public void forEachOrdered(Consumer<? super T> action) {
268             s.forEachOrdered(action);
269         }
270 
271         @Override
toArray()272         public Object[] toArray() {
273             return s.toArray();
274         }
275 
276         @Override
toArray(IntFunction<A[]> generator)277         public <A> A[] toArray(IntFunction<A[]> generator) {
278             return s.toArray(generator);
279         }
280 
281         @Override
reduce(T identity, BinaryOperator<T> accumulator)282         public T reduce(T identity, BinaryOperator<T> accumulator) {
283             return s.reduce(identity, accumulator);
284         }
285 
286         @Override
reduce(BinaryOperator<T> accumulator)287         public Optional<T> reduce(BinaryOperator<T> accumulator) {
288             return s.reduce(accumulator);
289         }
290 
291         @Override
reduce(U identity, BiFunction<U, ? super T, U> accumulator, BinaryOperator<U> combiner)292         public <U> U reduce(U identity, BiFunction<U, ? super T, U> accumulator, BinaryOperator<U> combiner) {
293             return s.reduce(identity, accumulator, combiner);
294         }
295 
296         @Override
collect(Supplier<R> supplier, BiConsumer<R, ? super T> accumulator, BiConsumer<R, R> combiner)297         public <R> R collect(Supplier<R> supplier, BiConsumer<R, ? super T> accumulator, BiConsumer<R, R> combiner) {
298             return s.collect(supplier, accumulator, combiner);
299         }
300 
301         @Override
collect(Collector<? super T, A, R> collector)302         public <R, A> R collect(Collector<? super T, A, R> collector) {
303             return s.collect(collector);
304         }
305 
306         @Override
min(Comparator<? super T> comparator)307         public Optional<T> min(Comparator<? super T> comparator) {
308             return s.min(comparator);
309         }
310 
311         @Override
max(Comparator<? super T> comparator)312         public Optional<T> max(Comparator<? super T> comparator) {
313             return s.max(comparator);
314         }
315 
316         @Override
count()317         public long count() {
318             return s.count();
319         }
320 
321         @Override
anyMatch(Predicate<? super T> predicate)322         public boolean anyMatch(Predicate<? super T> predicate) {
323             return s.anyMatch(predicate);
324         }
325 
326         @Override
allMatch(Predicate<? super T> predicate)327         public boolean allMatch(Predicate<? super T> predicate) {
328             return s.allMatch(predicate);
329         }
330 
331         @Override
noneMatch(Predicate<? super T> predicate)332         public boolean noneMatch(Predicate<? super T> predicate) {
333             return s.noneMatch(predicate);
334         }
335 
336         @Override
findFirst()337         public Optional<T> findFirst() {
338             return s.findFirst();
339         }
340 
341         @Override
findAny()342         public Optional<T> findAny() {
343             return s.findAny();
344         }
345 
346         @Override
iterator()347         public Iterator<T> iterator() {
348             return s.iterator();
349         }
350 
351         @Override
spliterator()352         public Spliterator<T> spliterator() {
353             return s.spliterator();
354         }
355 
356         @Override
isParallel()357         public boolean isParallel() {
358             return s.isParallel();
359         }
360 
361         @Override
sequential()362         public Stream<T> sequential() {
363             return s.sequential();
364         }
365 
366         @Override
parallel()367         public Stream<T> parallel() {
368             return s.parallel();
369         }
370 
371         @Override
unordered()372         public Stream<T> unordered() {
373             return s.unordered();
374         }
375 
376         @Override
onClose(Runnable closeHandler)377         public Stream<T> onClose(Runnable closeHandler) {
378             return s.onClose(closeHandler);
379         }
380 
381         @Override
close()382         public void close() {
383             s.close();
384         }
385     }
386 
387     static final class DefaultMethodIntStream implements IntStream {
388         final IntStream s;
389 
DefaultMethodIntStream(IntStream s)390         public DefaultMethodIntStream(IntStream s) {
391             this.s = s;
392         }
393 
394 
395         // Delegating non-default methods
396 
397         @Override
filter(IntPredicate predicate)398         public IntStream filter(IntPredicate predicate) {
399             return s.filter(predicate);
400         }
401 
402         @Override
map(IntUnaryOperator mapper)403         public IntStream map(IntUnaryOperator mapper) {
404             return s.map(mapper);
405         }
406 
407         @Override
mapToObj(IntFunction<? extends U> mapper)408         public <U> Stream<U> mapToObj(IntFunction<? extends U> mapper) {
409             return s.mapToObj(mapper);
410         }
411 
412         @Override
mapToLong(IntToLongFunction mapper)413         public LongStream mapToLong(IntToLongFunction mapper) {
414             return s.mapToLong(mapper);
415         }
416 
417         @Override
mapToDouble(IntToDoubleFunction mapper)418         public DoubleStream mapToDouble(IntToDoubleFunction mapper) {
419             return s.mapToDouble(mapper);
420         }
421 
422         @Override
flatMap(IntFunction<? extends IntStream> mapper)423         public IntStream flatMap(IntFunction<? extends IntStream> mapper) {
424             return s.flatMap(mapper);
425         }
426 
427         @Override
distinct()428         public IntStream distinct() {
429             return s.distinct();
430         }
431 
432         @Override
sorted()433         public IntStream sorted() {
434             return s.sorted();
435         }
436 
437         @Override
peek(IntConsumer action)438         public IntStream peek(IntConsumer action) {
439             return s.peek(action);
440         }
441 
442         @Override
limit(long maxSize)443         public IntStream limit(long maxSize) {
444             return s.limit(maxSize);
445         }
446 
447         @Override
skip(long n)448         public IntStream skip(long n) {
449             return s.skip(n);
450         }
451 
452         @Override
forEach(IntConsumer action)453         public void forEach(IntConsumer action) {
454             s.forEach(action);
455         }
456 
457         @Override
forEachOrdered(IntConsumer action)458         public void forEachOrdered(IntConsumer action) {
459             s.forEachOrdered(action);
460         }
461 
462         @Override
toArray()463         public int[] toArray() {
464             return s.toArray();
465         }
466 
467         @Override
reduce(int identity, IntBinaryOperator op)468         public int reduce(int identity, IntBinaryOperator op) {
469             return s.reduce(identity, op);
470         }
471 
472         @Override
reduce(IntBinaryOperator op)473         public OptionalInt reduce(IntBinaryOperator op) {
474             return s.reduce(op);
475         }
476 
477         @Override
collect(Supplier<R> supplier, ObjIntConsumer<R> accumulator, BiConsumer<R, R> combiner)478         public <R> R collect(Supplier<R> supplier, ObjIntConsumer<R> accumulator, BiConsumer<R, R> combiner) {
479             return s.collect(supplier, accumulator, combiner);
480         }
481 
482         @Override
sum()483         public int sum() {
484             return s.sum();
485         }
486 
487         @Override
min()488         public OptionalInt min() {
489             return s.min();
490         }
491 
492         @Override
max()493         public OptionalInt max() {
494             return s.max();
495         }
496 
497         @Override
count()498         public long count() {
499             return s.count();
500         }
501 
502         @Override
average()503         public OptionalDouble average() {
504             return s.average();
505         }
506 
507         @Override
summaryStatistics()508         public IntSummaryStatistics summaryStatistics() {
509             return s.summaryStatistics();
510         }
511 
512         @Override
anyMatch(IntPredicate predicate)513         public boolean anyMatch(IntPredicate predicate) {
514             return s.anyMatch(predicate);
515         }
516 
517         @Override
allMatch(IntPredicate predicate)518         public boolean allMatch(IntPredicate predicate) {
519             return s.allMatch(predicate);
520         }
521 
522         @Override
noneMatch(IntPredicate predicate)523         public boolean noneMatch(IntPredicate predicate) {
524             return s.noneMatch(predicate);
525         }
526 
527         @Override
findFirst()528         public OptionalInt findFirst() {
529             return s.findFirst();
530         }
531 
532         @Override
findAny()533         public OptionalInt findAny() {
534             return s.findAny();
535         }
536 
537         @Override
asLongStream()538         public LongStream asLongStream() {
539             return s.asLongStream();
540         }
541 
542         @Override
asDoubleStream()543         public DoubleStream asDoubleStream() {
544             return s.asDoubleStream();
545         }
546 
547         @Override
boxed()548         public Stream<Integer> boxed() {
549             return s.boxed();
550         }
551 
552         @Override
sequential()553         public IntStream sequential() {
554             return s.sequential();
555         }
556 
557         @Override
parallel()558         public IntStream parallel() {
559             return s.parallel();
560         }
561 
562         @Override
iterator()563         public PrimitiveIterator.OfInt iterator() {
564             return s.iterator();
565         }
566 
567         @Override
spliterator()568         public Spliterator.OfInt spliterator() {
569             return s.spliterator();
570         }
571 
572         @Override
isParallel()573         public boolean isParallel() {
574             return s.isParallel();
575         }
576 
577         @Override
unordered()578         public IntStream unordered() {
579             return s.unordered();
580         }
581 
582         @Override
onClose(Runnable closeHandler)583         public IntStream onClose(Runnable closeHandler) {
584             return s.onClose(closeHandler);
585         }
586 
587         @Override
close()588         public void close() {
589             s.close();
590         }
591     }
592 
593     static final class DefaultMethodLongStream implements LongStream {
594         final LongStream s;
595 
DefaultMethodLongStream(LongStream s)596         public DefaultMethodLongStream(LongStream s) {
597             this.s = s;
598         }
599 
600 
601         // Delegating non-default methods
602 
603         @Override
forEach(LongConsumer action)604         public void forEach(LongConsumer action) {
605             s.forEach(action);
606         }
607 
608         @Override
filter(LongPredicate predicate)609         public LongStream filter(LongPredicate predicate) {
610             return s.filter(predicate);
611         }
612 
613         @Override
map(LongUnaryOperator mapper)614         public LongStream map(LongUnaryOperator mapper) {
615             return s.map(mapper);
616         }
617 
618         @Override
mapToObj(LongFunction<? extends U> mapper)619         public <U> Stream<U> mapToObj(LongFunction<? extends U> mapper) {
620             return s.mapToObj(mapper);
621         }
622 
623         @Override
mapToInt(LongToIntFunction mapper)624         public IntStream mapToInt(LongToIntFunction mapper) {
625             return s.mapToInt(mapper);
626         }
627 
628         @Override
mapToDouble(LongToDoubleFunction mapper)629         public DoubleStream mapToDouble(LongToDoubleFunction mapper) {
630             return s.mapToDouble(mapper);
631         }
632 
633         @Override
flatMap(LongFunction<? extends LongStream> mapper)634         public LongStream flatMap(LongFunction<? extends LongStream> mapper) {
635             return s.flatMap(mapper);
636         }
637 
638         @Override
distinct()639         public LongStream distinct() {
640             return s.distinct();
641         }
642 
643         @Override
sorted()644         public LongStream sorted() {
645             return s.sorted();
646         }
647 
648         @Override
peek(LongConsumer action)649         public LongStream peek(LongConsumer action) {
650             return s.peek(action);
651         }
652 
653         @Override
limit(long maxSize)654         public LongStream limit(long maxSize) {
655             return s.limit(maxSize);
656         }
657 
658         @Override
skip(long n)659         public LongStream skip(long n) {
660             return s.skip(n);
661         }
662 
663         @Override
forEachOrdered(LongConsumer action)664         public void forEachOrdered(LongConsumer action) {
665             s.forEachOrdered(action);
666         }
667 
668         @Override
toArray()669         public long[] toArray() {
670             return s.toArray();
671         }
672 
673         @Override
reduce(long identity, LongBinaryOperator op)674         public long reduce(long identity, LongBinaryOperator op) {
675             return s.reduce(identity, op);
676         }
677 
678         @Override
reduce(LongBinaryOperator op)679         public OptionalLong reduce(LongBinaryOperator op) {
680             return s.reduce(op);
681         }
682 
683         @Override
collect(Supplier<R> supplier, ObjLongConsumer<R> accumulator, BiConsumer<R, R> combiner)684         public <R> R collect(Supplier<R> supplier, ObjLongConsumer<R> accumulator, BiConsumer<R, R> combiner) {
685             return s.collect(supplier, accumulator, combiner);
686         }
687 
688         @Override
sum()689         public long sum() {
690             return s.sum();
691         }
692 
693         @Override
min()694         public OptionalLong min() {
695             return s.min();
696         }
697 
698         @Override
max()699         public OptionalLong max() {
700             return s.max();
701         }
702 
703         @Override
count()704         public long count() {
705             return s.count();
706         }
707 
708         @Override
average()709         public OptionalDouble average() {
710             return s.average();
711         }
712 
713         @Override
summaryStatistics()714         public LongSummaryStatistics summaryStatistics() {
715             return s.summaryStatistics();
716         }
717 
718         @Override
anyMatch(LongPredicate predicate)719         public boolean anyMatch(LongPredicate predicate) {
720             return s.anyMatch(predicate);
721         }
722 
723         @Override
allMatch(LongPredicate predicate)724         public boolean allMatch(LongPredicate predicate) {
725             return s.allMatch(predicate);
726         }
727 
728         @Override
noneMatch(LongPredicate predicate)729         public boolean noneMatch(LongPredicate predicate) {
730             return s.noneMatch(predicate);
731         }
732 
733         @Override
findFirst()734         public OptionalLong findFirst() {
735             return s.findFirst();
736         }
737 
738         @Override
findAny()739         public OptionalLong findAny() {
740             return s.findAny();
741         }
742 
743         @Override
asDoubleStream()744         public DoubleStream asDoubleStream() {
745             return s.asDoubleStream();
746         }
747 
748         @Override
boxed()749         public Stream<Long> boxed() {
750             return s.boxed();
751         }
752 
753         @Override
sequential()754         public LongStream sequential() {
755             return s.sequential();
756         }
757 
758         @Override
parallel()759         public LongStream parallel() {
760             return s.parallel();
761         }
762 
763         @Override
iterator()764         public PrimitiveIterator.OfLong iterator() {
765             return s.iterator();
766         }
767 
768         @Override
spliterator()769         public Spliterator.OfLong spliterator() {
770             return s.spliterator();
771         }
772 
773         @Override
isParallel()774         public boolean isParallel() {
775             return s.isParallel();
776         }
777 
778         @Override
unordered()779         public LongStream unordered() {
780             return s.unordered();
781         }
782 
783         @Override
onClose(Runnable closeHandler)784         public LongStream onClose(Runnable closeHandler) {
785             return s.onClose(closeHandler);
786         }
787 
788         @Override
close()789         public void close() {
790             s.close();
791         }
792     }
793 
794     static final class DefaultMethodDoubleStream implements DoubleStream {
795         final DoubleStream s;
796 
DefaultMethodDoubleStream(DoubleStream s)797         public DefaultMethodDoubleStream(DoubleStream s) {
798             this.s = s;
799         }
800 
801         @Override
filter(DoublePredicate predicate)802         public DoubleStream filter(DoublePredicate predicate) {
803             return s.filter(predicate);
804         }
805 
806         @Override
map(DoubleUnaryOperator mapper)807         public DoubleStream map(DoubleUnaryOperator mapper) {
808             return s.map(mapper);
809         }
810 
811         @Override
mapToObj(DoubleFunction<? extends U> mapper)812         public <U> Stream<U> mapToObj(DoubleFunction<? extends U> mapper) {
813             return s.mapToObj(mapper);
814         }
815 
816         @Override
mapToInt(DoubleToIntFunction mapper)817         public IntStream mapToInt(DoubleToIntFunction mapper) {
818             return s.mapToInt(mapper);
819         }
820 
821         @Override
mapToLong(DoubleToLongFunction mapper)822         public LongStream mapToLong(DoubleToLongFunction mapper) {
823             return s.mapToLong(mapper);
824         }
825 
826         @Override
flatMap(DoubleFunction<? extends DoubleStream> mapper)827         public DoubleStream flatMap(DoubleFunction<? extends DoubleStream> mapper) {
828             return s.flatMap(mapper);
829         }
830 
831         @Override
distinct()832         public DoubleStream distinct() {
833             return s.distinct();
834         }
835 
836         @Override
sorted()837         public DoubleStream sorted() {
838             return s.sorted();
839         }
840 
841         @Override
peek(DoubleConsumer action)842         public DoubleStream peek(DoubleConsumer action) {
843             return s.peek(action);
844         }
845 
846         @Override
limit(long maxSize)847         public DoubleStream limit(long maxSize) {
848             return s.limit(maxSize);
849         }
850 
851         @Override
skip(long n)852         public DoubleStream skip(long n) {
853             return s.skip(n);
854         }
855 
856         @Override
forEach(DoubleConsumer action)857         public void forEach(DoubleConsumer action) {
858             s.forEach(action);
859         }
860 
861         @Override
forEachOrdered(DoubleConsumer action)862         public void forEachOrdered(DoubleConsumer action) {
863             s.forEachOrdered(action);
864         }
865 
866         @Override
toArray()867         public double[] toArray() {
868             return s.toArray();
869         }
870 
871         @Override
reduce(double identity, DoubleBinaryOperator op)872         public double reduce(double identity, DoubleBinaryOperator op) {
873             return s.reduce(identity, op);
874         }
875 
876         @Override
reduce(DoubleBinaryOperator op)877         public OptionalDouble reduce(DoubleBinaryOperator op) {
878             return s.reduce(op);
879         }
880 
881         @Override
collect(Supplier<R> supplier, ObjDoubleConsumer<R> accumulator, BiConsumer<R, R> combiner)882         public <R> R collect(Supplier<R> supplier, ObjDoubleConsumer<R> accumulator, BiConsumer<R, R> combiner) {
883             return s.collect(supplier, accumulator, combiner);
884         }
885 
886         @Override
sum()887         public double sum() {
888             return s.sum();
889         }
890 
891         @Override
min()892         public OptionalDouble min() {
893             return s.min();
894         }
895 
896         @Override
max()897         public OptionalDouble max() {
898             return s.max();
899         }
900 
901         @Override
count()902         public long count() {
903             return s.count();
904         }
905 
906         @Override
average()907         public OptionalDouble average() {
908             return s.average();
909         }
910 
911         @Override
summaryStatistics()912         public DoubleSummaryStatistics summaryStatistics() {
913             return s.summaryStatistics();
914         }
915 
916         @Override
anyMatch(DoublePredicate predicate)917         public boolean anyMatch(DoublePredicate predicate) {
918             return s.anyMatch(predicate);
919         }
920 
921         @Override
allMatch(DoublePredicate predicate)922         public boolean allMatch(DoublePredicate predicate) {
923             return s.allMatch(predicate);
924         }
925 
926         @Override
noneMatch(DoublePredicate predicate)927         public boolean noneMatch(DoublePredicate predicate) {
928             return s.noneMatch(predicate);
929         }
930 
931         @Override
findFirst()932         public OptionalDouble findFirst() {
933             return s.findFirst();
934         }
935 
936         @Override
findAny()937         public OptionalDouble findAny() {
938             return s.findAny();
939         }
940 
941         @Override
boxed()942         public Stream<Double> boxed() {
943             return s.boxed();
944         }
945 
946         @Override
sequential()947         public DoubleStream sequential() {
948             return s.sequential();
949         }
950 
951         @Override
parallel()952         public DoubleStream parallel() {
953             return s.parallel();
954         }
955 
956         @Override
iterator()957         public PrimitiveIterator.OfDouble iterator() {
958             return s.iterator();
959         }
960 
961         @Override
spliterator()962         public Spliterator.OfDouble spliterator() {
963             return s.spliterator();
964         }
965 
966         @Override
isParallel()967         public boolean isParallel() {
968             return s.isParallel();
969         }
970 
971         @Override
unordered()972         public DoubleStream unordered() {
973             return s.unordered();
974         }
975 
976         @Override
onClose(Runnable closeHandler)977         public DoubleStream onClose(Runnable closeHandler) {
978             return s.onClose(closeHandler);
979         }
980 
981         @Override
close()982         public void close() {
983             s.close();
984         }
985     }
986 }
987