org.eclipse.rdf4j.common.iteration

## Class Iterations

- java.lang.Object
- - org.eclipse.rdf4j.common.iteration.Iterations

- Direct Known Subclasses:
    QueryResults

      public class Iterations
      extends Object

  This class consists exclusively of static methods that operate on or return Iterations. It is the Iteration-equivalent of `java.util.Collections`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Iterations()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <E,X extends Exception,C extends Collection<E>> C` | `addAll(Iteration<? extends E,X> iter, C collection)` Adds all elements from the supplied Iteration to the specified collection.
    `static <E,X extends Exception> List<E>` | `asList(Iteration<? extends E,X> iter)` Get a List containing all elements obtained from the specified Iteration.
    `static <E,X extends Exception> Set<E>` | `asSet(Iteration<? extends E,X> iter)` Get a Set containing all elements obtained from the specified Iteration.
    `static <X extends Exception> void` | `closeCloseable(Iteration<?,X> iter)` Closes the supplied Iteration if it is an instance of `CloseableIteration`, otherwise the request is ignored.
    `static <T> java.util.stream.Stream<T>` | `stream(Iteration<T,? extends Exception> iteration)` Get a sequential `Stream` with the supplied `Iteration` as its source.
    `static <X extends Exception> String` | `toString(Iteration<?,X> iter, String separator)` Converts an Iteration to a string by concatenating all of the string representations of objects in the Iteration, divided by a separator.
    `static <X extends Exception> void` | `toString(Iteration<?,X> iter, String separator, StringBuilder sb)` Converts an Iteration to a string by concatenating all of the string representations of objects in the Iteration, divided by a separator.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Iterations

          public Iterations()

  - ### Method Detail

    - #### asList

          public static <E,X extends Exception> List<E> asList(Iteration<? extends E,X> iter)
                                                        throws X extends Exception

      Get a List containing all elements obtained from the specified Iteration.
      Parameters:
        `iter` - the Iteration to get the elements from
      Returns:
        a List containing all elements obtained from the specified Iteration.
      Throws:
        `X extends Exception`

    - #### asSet

          public static <E,X extends Exception> Set<E> asSet(Iteration<? extends E,X> iter)
                                                      throws X extends Exception

      Get a Set containing all elements obtained from the specified Iteration.
      Parameters:
        `iter` - the Iteration to get the elements from
      Returns:
        a Set containing all elements obtained from the specified Iteration.
      Throws:
        `X extends Exception`

    - #### addAll

          public static <E,X extends Exception,C extends Collection<E>> C addAll(Iteration<? extends E,X> iter,
                                                                                 C collection)
                                                                          throws X extends Exception

      Adds all elements from the supplied Iteration to the specified collection. If the supplied Iteration is an instance of `CloseableIteration` it is automatically closed after consumption.
      Parameters:
        `iter` - An Iteration containing elements to add to the container. If the Iteration is an instance of `CloseableIteration` it is automatically closed after consumption.
        `collection` - The collection to add the elements to.
      Returns:
        The `collection` object that was supplied to this method.
      Throws:
        `X extends Exception`

    - #### stream

          public static <T> java.util.stream.Stream<T> stream(Iteration<T,? extends Exception> iteration)

      Get a sequential `Stream` with the supplied `Iteration` as its source. If the source iteration is a `CloseableIteration`, it will be automatically closed by the stream when done. Any checked exceptions thrown at any point during stream processing will be propagated wrapped in a `RuntimeException`.
      Parameters:
        `iteration` - a source `Iteration` for the stream.
      Returns:
        a sequential `Stream` object which can be used to process the data from the source iteration.

    - #### closeCloseable

          public static <X extends Exception> void closeCloseable(Iteration<?,X> iter)
                                                           throws X extends Exception

      Closes the supplied Iteration if it is an instance of `CloseableIteration`, otherwise the request is ignored.
      Parameters:
        `iter` - The Iteration that should be closed.
      Throws:
        `X extends Exception`

    - #### toString

          public static <X extends Exception> String toString(Iteration<?,X> iter,
                                                              String separator)
                                                       throws X extends Exception

      Converts an Iteration to a string by concatenating all of the string representations of objects in the Iteration, divided by a separator.
      Parameters:
        `iter` - An Iteration over arbitrary objects that are expected to implement `Object.toString()`.
        `separator` - The separator to insert between the object strings.
      Returns:
        A String representation of the objects provided by the supplied Iteration.
      Throws:
        `X extends Exception`

    - #### toString

          public static <X extends Exception> void toString(Iteration<?,X> iter,
                                                            String separator,
                                                            StringBuilder sb)
                                                     throws X extends Exception

      Converts an Iteration to a string by concatenating all of the string representations of objects in the Iteration, divided by a separator.
      Parameters:
        `iter` - An Iteration over arbitrary objects that are expected to implement `Object.toString()`.
        `separator` - The separator to insert between the object strings.
        `sb` - A StringBuilder to append the Iteration string to.
      Throws:
        `X extends Exception`

Copyright © 2015-2022 Eclipse Foundation. All Rights Reserved.