Class 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 Detail

      • Iterations

        public Iterations()
    • Method Detail

      • asList

        public static <E> List<E> asList​(CloseableIteration<? extends E> iteration)
        Get a List containing all elements obtained from the specified iteration.
        Parameters:
        iteration - the CloseableIteration to get the elements from
        Returns:
        a List containing all elements obtained from the specified iteration.
      • asSet

        public static <E> Set<E> asSet​(CloseableIteration<? extends E> iteration)
        Get a Set containing all elements obtained from the specified iteration.
        Parameters:
        iteration - the CloseableIteration to get the elements from
        Returns:
        a Set containing all elements obtained from the specified iteration.
      • addAll

        public static <E,​C extends Collection<E>> C addAll​(CloseableIteration<? extends E> iteration,
                                                                 C collection)
        Adds all elements from the supplied CloseableIteration to the specified collection then closes the CloseableIteration.
        Parameters:
        iteration - A CloseableIteration containing elements to add to the container.
        collection - The collection to add the elements to.
        Returns:
        The collection object that was supplied to this method.
      • stream

        public static <T> Stream<T> stream​(CloseableIteration<T> iteration)
        Get a sequential Stream with the supplied CloseableIteration as its source. The source iteration 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 CloseableIteration for the stream.
        Returns:
        a sequential Stream object which can be used to process the data from the source iteration.
      • toString

        public static String toString​(CloseableIteration<?> iteration,
                                      String separator)
        Converts a CloseableIteration to a string by concatenating all the string representations of objects in the iteration, divided by a separator.
        Parameters:
        iteration - A CloseableIteration 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.
      • toString

        public static void toString​(CloseableIteration<?> iteration,
                                    String separator,
                                    StringBuilder sb)
        Converts a CloseableIteration to a string by concatenating all the string representations of objects in the iteration, divided by a separator.
        Parameters:
        iteration - A CloseableIteration 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.
      • asSet

        public static <E> Set<E> asSet​(CloseableIteration<? extends E> iteration,
                                       Supplier<Set<E>> setMaker)
        Get a Set containing all elements obtained from the specified iteration.
        Parameters:
        iteration - the iteration to get the elements from
        setMaker - the Supplier that constructs a new set
        Returns:
        a Set containing all elements obtained from the specified iteration.