src/java.base/share/classes/java/util/stream/Collector.java
changeset 58459 e25b317d0350
parent 47216 71c04702a3d5
equal deleted inserted replaced
58458:3ab9f0464a7d 58459:e25b317d0350
     1 /*
     1 /*
     2  * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    30 import java.util.Set;
    30 import java.util.Set;
    31 import java.util.function.BiConsumer;
    31 import java.util.function.BiConsumer;
    32 import java.util.function.BinaryOperator;
    32 import java.util.function.BinaryOperator;
    33 import java.util.function.Function;
    33 import java.util.function.Function;
    34 import java.util.function.Supplier;
    34 import java.util.function.Supplier;
       
    35 
       
    36 // A compilation test for the code snippets in this class-level javadoc can be found at:
       
    37 // test/jdk/java/util/stream/test/org/openjdk/tests/java/util/stream/CollectorExample.java
       
    38 // The test needs to be updated if the examples in this javadoc change or new examples are added.
    35 
    39 
    36 /**
    40 /**
    37  * A <a href="package-summary.html#Reduction">mutable reduction operation</a> that
    41  * A <a href="package-summary.html#Reduction">mutable reduction operation</a> that
    38  * accumulates input elements into a mutable result container, optionally transforming
    42  * accumulates input elements into a mutable result container, optionally transforming
    39  * the accumulated result into a final representation after all input elements
    43  * the accumulated result into a final representation after all input elements
   152  *
   156  *
   153  * @apiNote
   157  * @apiNote
   154  * Performing a reduction operation with a {@code Collector} should produce a
   158  * Performing a reduction operation with a {@code Collector} should produce a
   155  * result equivalent to:
   159  * result equivalent to:
   156  * <pre>{@code
   160  * <pre>{@code
   157  *     R container = collector.supplier().get();
   161  *     A container = collector.supplier().get();
   158  *     for (T t : data)
   162  *     for (T t : data)
   159  *         collector.accumulator().accept(container, t);
   163  *         collector.accumulator().accept(container, t);
   160  *     return collector.finisher().apply(container);
   164  *     return collector.finisher().apply(container);
   161  * }</pre>
   165  * }</pre>
   162  *
   166  *