Class Iterations
java.lang.Object
org.eclipse.rdf4j.common.iteration.Iterations
- Direct Known Subclasses:
QueryResults
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic <E,C extends Collection<E>>
CaddAll(CloseableIteration<? extends E> iteration, C collection) Adds all elements from the suppliedCloseableIterationto the specified collection then closes theCloseableIteration.static <E> List<E>asList(CloseableIteration<? extends E> iteration) Get a List containing all elements obtained from the specified iteration.static <E> Set<E>asSet(CloseableIteration<? extends E> iteration) Get a Set containing all elements obtained from the specified iteration.static <E> Set<E>asSet(CloseableIteration<? extends E> iteration, Supplier<Set<E>> setMaker) Get a Set containing all elements obtained from the specified iteration.static <T> Stream<T>stream(CloseableIteration<T> iteration) Get a sequentialStreamwith the suppliedCloseableIterationas its source.static StringtoString(CloseableIteration<?> iteration, String separator) Converts aCloseableIterationto a string by concatenating all the string representations of objects in the iteration, divided by a separator.static voidtoString(CloseableIteration<?> iteration, String separator, StringBuilder sb) Converts aCloseableIterationto a string by concatenating all the string representations of objects in the iteration, divided by a separator.
-
Constructor Details
-
Iterations
public Iterations()
-
-
Method Details
-
asList
Get a List containing all elements obtained from the specified iteration.- Parameters:
iteration- theCloseableIterationto get the elements from- Returns:
- a List containing all elements obtained from the specified iteration.
-
asSet
Get a Set containing all elements obtained from the specified iteration.- Parameters:
iteration- theCloseableIterationto 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 suppliedCloseableIterationto the specified collection then closes theCloseableIteration.- Parameters:
iteration- ACloseableIterationcontaining 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
Get a sequentialStreamwith the suppliedCloseableIterationas 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 aRuntimeException.- Parameters:
iteration- a sourceCloseableIterationfor the stream.- Returns:
- a sequential
Streamobject which can be used to process the data from the source iteration.
-
toString
Converts aCloseableIterationto a string by concatenating all the string representations of objects in the iteration, divided by a separator.- Parameters:
iteration- ACloseableIterationover arbitrary objects that are expected to implementObject.toString().separator- The separator to insert between the object strings.- Returns:
- A String representation of the objects provided by the supplied iteration.
-
toString
Converts aCloseableIterationto a string by concatenating all the string representations of objects in the iteration, divided by a separator.- Parameters:
iteration- ACloseableIterationover arbitrary objects that are expected to implementObject.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 fromsetMaker- the Supplier that constructs a new set- Returns:
- a Set containing all elements obtained from the specified iteration.
-