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
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E,
X extends Exception, C extends Collection<E>>
CAdds all elements from the supplied Iteration to the specified collection.Get a List containing all elements obtained from the specified Iteration.Get a Set containing all elements obtained from the specified Iteration.Get a Set containing all elements obtained from the specified Iteration.static <X extends Exception>
voidcloseCloseable
(Iteration<?, X> iter) Closes the supplied Iteration if it is an instance ofCloseableIteration
, otherwise the request is ignored.static <T> Stream<T>
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>
voidtoString
(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.
-
Constructor Details
-
Iterations
public Iterations()
-
-
Method Details
-
asList
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
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 addAllC extends Collection<E>> (Iteration<? extends E, X> iter, C collection) throws XAdds all elements from the supplied Iteration to the specified collection. If the supplied Iteration is an instance ofCloseableIteration
it is automatically closed after consumption.- Parameters:
iter
- An Iteration containing elements to add to the container. If the Iteration is an instance ofCloseableIteration
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
Get a sequentialStream
with the suppliedIteration
as its source. If the source iteration is aCloseableIteration
, 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 aRuntimeException
. -
closeCloseable
Closes the supplied Iteration if it is an instance ofCloseableIteration
, otherwise the request is ignored.- Parameters:
iter
- The Iteration that should be closed.- Throws:
X extends Exception
-
toString
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 implementObject.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 XConverts 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 implementObject.toString()
.separator
- The separator to insert between the object strings.sb
- A StringBuilder to append the Iteration string to.- Throws:
X extends Exception
-
asSet
public static <E,X extends Exception> Set<E> asSet(Iteration<? extends E, ? extends X> arg2, Supplier<Set<E>> setMaker) throws XGet a Set containing all elements obtained from the specified Iteration.- Parameters:
iter
- 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.
- Throws:
X extends Exception
-