OpenJDK / lambda / lambda / jdk
changeset 8243:76ac19e61df1
Fix javadoc issues
author | briangoetz |
---|---|
date | Wed, 17 Apr 2013 14:41:09 -0400 |
parents | 49c020792613 |
children | 8657066e8307 |
files | src/share/classes/java/util/stream/Collectors.java src/share/classes/java/util/stream/DoubleStream.java src/share/classes/java/util/stream/IntStream.java src/share/classes/java/util/stream/LongStream.java src/share/classes/java/util/stream/Stream.java src/share/classes/java/util/stream/package-info.java |
diffstat | 6 files changed, 44 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/java/util/stream/Collectors.java Wed Apr 17 13:50:53 2013 -0400 +++ b/src/share/classes/java/util/stream/Collectors.java Wed Apr 17 14:41:09 2013 -0400 @@ -305,6 +305,8 @@ * * @return A {@code Collector} which collects String elements into a * {@code StringJoiner}, in encounter order + * @param separator the separator to be used between each element + * added to the StringJoiner */ public static Collector<CharSequence, StringJoiner> toStringJoiner(String separator) { BinaryOperator<StringJoiner> merger = (sj, other) -> { @@ -451,6 +453,7 @@ * @param identity The identity value for the reduction (also, the value * that is returned when there are no input elements) * @param op A {@code BinaryOperator<T>} used to reduce the input elements + * @param <T> Element type for the input and output of the reduction * @return A {@code Collector} which implements the reduction operation * @see #reducing(BinaryOperator) * @see #reducing(Object, Function, BinaryOperator) @@ -479,6 +482,7 @@ * = people.stream().collect(groupingBy(Person::getCity, reducing(tallerOf))); * }</pre> * @param op A {@code BinaryOperator<T>} used to reduce the input elements + * @param <T> Element type for the input and output of the reduction * @return A {@code Collector} which implements the reduction operation * @see #reducing(Object, BinaryOperator) * @see #reducing(Object, Function, BinaryOperator) @@ -511,6 +515,8 @@ * reducing(Person::getLastName, longerOf))); * }</pre> * + * @param identity The identity value for the reduction (also, the value + * that is returned when there are no input elements) * @param mapper A mapping function to apply to each input value * @param op A {@code BinaryOperator<U>} used to reduce the mapped values * @param <T> The type of the input elements @@ -627,6 +633,7 @@ * @param <T> The type of the input elements * @param <K> The type of the keys * @param <D> The result type of the downstream reduction + * @param <M> The type of the resulting {@code Map} * @return A {@code Collector} implementing the cascaded group-by operation * @see #groupingBy(Function, Collector) * @see #groupingBy(Function) @@ -751,9 +758,12 @@ * * @param classifier The classifier function mapping input elements to keys * @param downstream A {@code Collector} implementing the downstream reduction + * @param mapFactory A function which, when called, produces a new empty + * {@code ConcurrentMap} of the desired type * @param <T> The type of the input elements * @param <K> The type of the keys * @param <D> The result type of the downstream reduction + * @param <M> The type of the resulting {@code ConcurrentMap} * @return A {@code Collector} implementing the cascaded group-by operation * @see #groupingByConcurrent(Function) * @see #groupingByConcurrent(Function, Collector) @@ -988,6 +998,7 @@ * @param <T> The type of the input elements * @param <K> The output type of the key mapping function * @param <U> The output type of the value mapping function + * @param <M> The type of the resulting {@code Map} * @param keyMapper The mapping function to produce keys * @param valueMapper The mapping function to produce values * @param mergeFunction A merge function, used to resolve collisions between @@ -1132,6 +1143,7 @@ * @param <T> The type of the input elements * @param <K> The output type of the key mapping function * @param <U> The output type of the value mapping function + * @param <M> The type of the resulting {@code ConcurrentMap} * @param keyMapper The mapping function to produce keys * @param valueMapper The mapping function to produce values * @param mergeFunction A merge function, used to resolve collisions between
--- a/src/share/classes/java/util/stream/DoubleStream.java Wed Apr 17 13:50:53 2013 -0400 +++ b/src/share/classes/java/util/stream/DoubleStream.java Wed Apr 17 14:41:09 2013 -0400 @@ -110,6 +110,7 @@ * @param mapper A <a href="package-summary.html#NonInterference"> * non-interfering, stateless</a> function to apply to * each element + * @param <U> The element type of the new stream * @return the new stream */ <U> Stream<U> mapToObj(DoubleFunction<? extends U> mapper); @@ -360,7 +361,8 @@ * result = element; * } * else - * result = accumulator.apply(result, element) + * result = accumulator.apply(result, element); + * } * return foundAny ? OptionalDouble.of(result) : OptionalDouble.empty(); * }</pre> *
--- a/src/share/classes/java/util/stream/IntStream.java Wed Apr 17 13:50:53 2013 -0400 +++ b/src/share/classes/java/util/stream/IntStream.java Wed Apr 17 14:41:09 2013 -0400 @@ -111,6 +111,7 @@ * @param mapper A <a href="package-summary.html#NonInterference"> * non-interfering, stateless</a> function to apply to * each element + * @param <U> The element type of the new stream * @return the new stream */ <U> Stream<U> mapToObj(IntFunction<? extends U> mapper); @@ -361,7 +362,8 @@ * result = element; * } * else - * result = accumulator.apply(result, element) + * result = accumulator.apply(result, element); + * } * return foundAny ? OptionalInt.of(result) : OptionalInt.empty(); * }</pre> *
--- a/src/share/classes/java/util/stream/LongStream.java Wed Apr 17 13:50:53 2013 -0400 +++ b/src/share/classes/java/util/stream/LongStream.java Wed Apr 17 14:41:09 2013 -0400 @@ -111,6 +111,7 @@ * @param mapper A <a href="package-summary.html#NonInterference"> * non-interfering, stateless</a> function to apply to * each element + * @param <U> The element type of the new stream * @return the new stream */ <U> Stream<U> mapToObj(LongFunction<? extends U> mapper); @@ -361,7 +362,8 @@ * result = element; * } * else - * result = accumulator.apply(result, element) + * result = accumulator.apply(result, element); + * } * return foundAny ? OptionalLong.of(result) : OptionalLong.empty(); * }</pre> *
--- a/src/share/classes/java/util/stream/Stream.java Wed Apr 17 13:50:53 2013 -0400 +++ b/src/share/classes/java/util/stream/Stream.java Wed Apr 17 14:41:09 2013 -0400 @@ -112,6 +112,7 @@ * @param mapper a <a href="package-summary.html#NonInterference"> * non-interfering, stateless</a> function to apply to * each element + * @param <R> The element type of the new stream * @return the new stream */ <R> Stream<R> map(Function<? super T, ? extends R> mapper); @@ -182,6 +183,7 @@ * @param mapper A <a href="package-summary.html#NonInterference"> * non-interfering, stateless</a> function to apply to * each element which produces a stream of new values + * @param <R> The element type of the new stream * @return the new stream */ <R> Stream<R> flatMap(Function<? super T, ? extends Stream<? extends R>> mapper); @@ -467,7 +469,8 @@ * result = element; * } * else - * result = accumulator.apply(result, element) + * result = accumulator.apply(result, element); + * } * return foundAny ? Optional.of(result) : Optional.empty(); * }</pre> *
--- a/src/share/classes/java/util/stream/package-info.java Wed Apr 17 13:50:53 2013 -0400 +++ b/src/share/classes/java/util/stream/package-info.java Wed Apr 17 14:41:09 2013 -0400 @@ -24,6 +24,8 @@ */ /** + * <h1>java.util.stream</h1> + * * Classes to support functional-style operations on streams of values, as in the following: * * <pre>{@code @@ -33,7 +35,7 @@ * }</pre> * * <p>Here we use {@code blocks}, which might be a {@code Collection}, as a source for a stream, - * and then perform a filter-map-reduce ({@code sum()} is an example of a {@link #Reduction reduction} + * and then perform a filter-map-reduce ({@code sum()} is an example of a <a href="package-summary.html#Reduction">reduction</a> * operation) on the stream to obtain the sum of the weights of the red blocks. * * <p>The key abstraction used in this approach is {@link java.util.stream.Stream}, as well as its primitive @@ -59,7 +61,7 @@ * * <h2><a name="StreamPipelines">Stream pipelines</a></h2> * - * <p>Streams are used to create <em>pipelines</em> of {@link #StreamOps operations}. A + * <p>Streams are used to create <em>pipelines</em> of <a href="package-summary.html#StreamOps">operations</a>. A * complete stream pipeline has several components: a source (which may be a {@code Collection}, * an array, a generator function, or an IO channel); zero or more <em>intermediate operations</em> * such as {@code Stream#filter} or {@code Stream#map}; and a <em>terminal operation</em> such @@ -170,7 +172,7 @@ * {@code HashSet}) are not. Some intermediate operations may impose an * encounter order on an otherwise unordered stream, such as * {@link java.util.stream.Stream#sorted()}, and others may render an ordered - * stream unordered (such as {@link {@link java.util.stream.Stream#unordered()}}). + * stream unordered (such as {@link java.util.stream.Stream#unordered()}). * Some terminal operations may ignore encounter order, such as * {@link java.util.stream.Stream#forEach}. * @@ -200,7 +202,7 @@ * with the {@link java.util.stream.Stream#unordered()} method may result in * improved parallel performance for some stateful or terminal operations. * - * <h2><a name="Non-Interference">Non-interference</h2> + * <h2><a name="Non-Interference">Non-interference</a></h2> * * The {@code java.util.stream} package enables you to execute possibly-parallel * bulk-data operations over a variety of data sources, including even non-thread-safe @@ -234,7 +236,7 @@ * * <h2>Side-effects</h2> * - * <h2><a name="Reduction">Reduction operations</h2> + * <h2><a name="Reduction">Reduction operations</a></h2> * * A <em>reduction</em> operation takes a stream of elements and processes them in a way * that reduces to a single value or summary description, such as finding the sum or maximum @@ -252,7 +254,7 @@ * }</pre> * However, there may be a significant advantage to preferring a {@link Stream#reduce reduce operation} * over a mutative accumulation such as the above -- a properly constructed reduce operation is - * inherently parallelizable, so long as the {@link BinaryOperator} has the right characteristics, + * inherently parallelizable, so long as the {@link java.util.function.BinaryOperator} has the right characteristics, * specifically that it is <a href="#Associativity">associative</a>. For example, given a * stream of numbers for which we want to find the sum, we can write: * <pre>{@code @@ -270,7 +272,7 @@ * * <p>Reduction parallellizes well since the implementation of {@code reduce} can operate on * subsets of the stream in parallel, and then combine the intermediate results to get the final - * correct answer. Even if you were to use a parallelizable form of the {@link forEach} method + * correct answer. Even if you were to use a parallelizable form of the {@link java.util.stream.Stream#forEach(Consumer) forEach()} method * in place of the original for-each loop above, you would still have to provide thread-safe * updates to the shared accumulating variable {@code sum}, and the required synchronization * would likely eliminate any performance gain from parallelism. Using a {@code reduce} method @@ -342,7 +344,7 @@ * is a mutable container for accumulating strings. We can use the same technique to * parallelize mutable reduction as we do with ordinary reduction. * - * </p>The mutable reduction operation is called {@link Stream#collect collect}, as it + * <p>The mutable reduction operation is called {@link java.util.stream.Stream#collect(Collector) collect()}, as it * collects together the desired results into a result container such as {@code StringBuilder}. * A {@code collect} operation requires three things: a factory function which will construct * new instances of the result container, an accumulating function that will update a result @@ -376,12 +378,12 @@ * ArrayList<String> strings = stream.map(Object::toString) * .collect(ArrayList::new, ArrayList::add, ArrayList::addAll); * }</pre> - * Here, our supplier is just the {@link ArrayList#ArrayList() ArrayList constructor}, the + * Here, our supplier is just the {@link java.util.ArrayList#ArrayList() ArrayList constructor}, the * accumulator adds the stringified element to an {@code ArrayList}, and the combiner simply - * uses {@link ArrayList#addAll addAll} to copy the strings from one container into the other. + * uses {@link java.util.ArrayList#addAll addAll} to copy the strings from one container into the other. * * <p>As with the regular reduction operation, the ability to parallelize only comes if an - * {@link #Associativity associativity} condition is met. The {@code combiner} is associative + * <a href="package-summary.html#Associativity">associativity</a> condition is met. The {@code combiner} is associative * if for result containers {@code r1}, {@code r2}, and {@code r3}: * <pre>{@code * combiner.accept(r1, r2); @@ -449,7 +451,7 @@ * to the parallel execution performance. We call this a <em>concurrent</em> reduction. * * <p>A {@link Collector} that supports concurrent reduction is marked with the - * {@link java.util.stream.Collector.Characteristics.CONCURRENT} characteristic. + * {@link java.util.stream.Collector.Characteristics#CONCURRENT} characteristic. * Having a concurrent collector is a necessary condition for performing a * concurrent reduction, but that alone is not sufficient. If you imagine multiple * accumulators depositing results into a shared container, the order in which @@ -458,12 +460,12 @@ * The {@link java.util.stream.Stream#collect(Collector)} * implementation will only perform a concurrent reduction if * <ul> - * <li>The stream is parallel</li>; + * <li>The stream is parallel;</li> * <li>The collector has the - * {@link java.util.stream.Collector.Characteristics.CONCURRENT} characteristic, + * {@link java.util.stream.Collector.Characteristics#CONCURRENT} characteristic, * and;</li> * <li>Either the stream is unordered, or the collector has the - * {@link java.util.stream.Collector.Characteristics.UNORDERED} characteristic. + * {@link java.util.stream.Collector.Characteristics#UNORDERED} characteristic. * </ul> * For example: * <pre>{@code @@ -481,7 +483,7 @@ * be constrained to implement either a sequential reduction or a merge-based * parallel reduction. * - * <a name="Associativity"><h2>Associativity</h2></a> + * <h2><a name="Associativity">Associativity</a></h2> * * An operator or function {@code op} is <em>associative</em> if the following holds: * <pre>{@code @@ -560,3 +562,4 @@ package java.util.stream; +import java.util.function.Consumer; \ No newline at end of file