Package: java.util.stream

## Interface Stream

- - ### Methods Summary

    Methods
    Return type | Name and parameters
    --- | ---
    `Stream` | `plus(Iterable rhs)` Returns a lazily concatenated stream whose elements are all the elements of this stream followed by all the elements of the Iterable object.
    `Stream` | `plus(Collection rhs)` Returns a lazily concatenated stream whose elements are all the elements of this stream followed by all the elements of the Collection object.
    `Stream` | `plus(Stream rhs)` Returns a lazily concatenated stream whose elements are all the elements of this stream followed by all the elements of the second stream.
    `Object[]` | `toArray(Class type)` Returns an array containing the elements of the stream.
    `List` | `toList()` Accumulates the elements of stream into a new List.
    `Set` | `toSet()` Accumulates the elements of stream into a new Set.

  - #### Methods inherited from interface java.util.stream.BaseStream

    `toList`, `toSet`

- - ### Methods Detail

    - #### public Stream plus(Iterable rhs)

      Returns a lazily concatenated stream whose elements are all the elements of this stream followed by all the elements of the Iterable object.

          import java.util.stream.Stream
          assert (Stream.of(1) + [2]).toList() == [1,2]
          assert (Stream.of(1) + []).toList() == [1]

      Parameters:
      Since:
        4.0.0

    - #### public Stream plus(Collection rhs)

      Returns a lazily concatenated stream whose elements are all the elements of this stream followed by all the elements of the Collection object.

          import java.util.stream.Stream
          assert (Stream.of(1) + [2]).toList() == [1,2]
          assert (Stream.of(1) + []).toList() == [1]

      Parameters:
      Since:
        4.0.0

    - #### public Stream plus(Stream rhs)

      Returns a lazily concatenated stream whose elements are all the elements of this stream followed by all the elements of the second stream.

          import java.util.stream.Stream
          assert (Stream.of(1) + Stream.<Integer>empty()).toList() == [1]
          assert (Stream.of(1) + Stream.of(2)).toList() == [1,2]
          assert (Stream.of(1) + [2].stream()).toList() == [1,2]

      Parameters:
      Since:
        4.0.0

    - #### public Object[] toArray(Class type)

      Returns an array containing the elements of the stream.

          import static groovy.test.GroovyAssert.shouldFail

          assert Arrays.equals([].stream().toArray(Object), new Object[0])
          assert Arrays.equals([].stream().toArray(String), new String[0])
          assert Arrays.equals([].stream().toArray(String[]), new String[0][])
          assert Arrays.equals(['x'].stream().toArray(Object), ['x'].toArray())
          assert Arrays.equals(['x'].stream().toArray(String), ['x'] as String[])
          assert Arrays.deepEquals([['x'] as String[]].stream().toArray(String[]), [['x'] as String[]] as String[][])
          assert Arrays.equals(['x'].stream().toArray(CharSequence), ['x'] as CharSequence[])

          shouldFail(ArrayStoreException) {
              ['x'].stream().toArray(Thread)
          }

          shouldFail(IllegalArgumentException) {
              ['x'].stream().toArray((Class) null)
          }

          // Stream#toArray(IntFunction) should still be used for closure literal:
          assert Arrays.equals(['x'].stream().toArray { n -> new String[n] }, ['x'] as String[])

          // Stream#toArray(IntFunction) should still be used for method reference:
          assert Arrays.equals(['x'].stream().toArray(String[]::new), ['x'] as String[])

      Parameters:
        `type` - the array element type
      Since:
        3.0.4

    - #### public List toList()

      Accumulates the elements of stream into a new List.

      Returns:
        a new `java.util.List` instance
      Since:
        2.5.0

    - #### public Set toSet()

      Accumulates the elements of stream into a new Set.

      Returns:
        a new `java.util.Set` instance
      Since:
        2.5.0