Class Iterators
- java.lang.Object
-
- org.apache.jackrabbit.spi.commons.iterator.Iterators
-
public final class Iterators extends Object
Historical utility class containing type safe adapters for some of the iterators of commons-collections.
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <T> Iterator<T>
arrayIterator(T[] values, int from, int to)
Returns an iterator for elements of an array ofvalues
.static <T> Iterator<T>
empty()
Returns an empty iterator of typeT
.static <T> Iterator<T>
filterIterator(Iterator<? extends T> iterator, Predicate<? super T> predicate)
Returns an iterator with elements from an originaliterator
where the givenpredicate
matches removed.static <T> Iterator<T>
filterIterator(Iterator<? extends T> iterator, Predicate<? super T> predicate)
Deprecated.static <T> Iterator<T>
iteratorChain(Collection<Iterator<? extends T>> iterators)
Returns an iterator for the concatenation of all the giveniterators
.static <T> Iterator<T>
iteratorChain(Iterator<? extends T>[] iterators)
Returns an iterator for the concatenation of all the giveniterators
.static <T> Iterator<T>
iteratorChain(Iterator<? extends T> iterator1, Iterator<? extends T> iterator2)
Returns an iterator for the concatenation ofiterator1
anditerator2
.static Iterator<Node>
nodes(NodeIterator nodeIterator)
Returns an iterator ofNode
from aNodeIterator
.static Iterator<Property>
properties(PropertyIterator propertyIterator)
Returns an iterator ofProperty
from aPropertyIterator
.static <T> Iterator<T>
singleton(T element)
Returns an iterator containing the single elementelement
of typeT
.static <S,R>
Iterator<R>transformIterator(Iterator<S> iterator, Transformer<S,R> transformer)
Returns an iterator with elements of an originaliterator
transformed by atransformer
.
-
-
-
Method Detail
-
singleton
public static <T> Iterator<T> singleton(T element)
Returns an iterator containing the single elementelement
of typeT
.- Type Parameters:
T
-- Parameters:
element
-- Returns:
-
empty
public static <T> Iterator<T> empty()
Returns an empty iterator of typeT
.- Type Parameters:
T
-- Returns:
-
iteratorChain
public static <T> Iterator<T> iteratorChain(Iterator<? extends T> iterator1, Iterator<? extends T> iterator2)
Returns an iterator for the concatenation ofiterator1
anditerator2
.- Type Parameters:
T
-- Parameters:
iterator1
-iterator2
-- Returns:
-
iteratorChain
public static <T> Iterator<T> iteratorChain(Iterator<? extends T>[] iterators)
Returns an iterator for the concatenation of all the giveniterators
.- Type Parameters:
T
-- Parameters:
iterators
-- Returns:
-
iteratorChain
public static <T> Iterator<T> iteratorChain(Collection<Iterator<? extends T>> iterators)
Returns an iterator for the concatenation of all the giveniterators
.- Type Parameters:
T
-- Parameters:
iterators
-- Returns:
-
arrayIterator
public static <T> Iterator<T> arrayIterator(T[] values, int from, int to)
Returns an iterator for elements of an array ofvalues
.- Type Parameters:
T
-- Parameters:
values
- the array to iterate over.from
- the index to start iterating at.to
- the index to finish iterating at.- Returns:
-
filterIterator
@Deprecated public static <T> Iterator<T> filterIterator(Iterator<? extends T> iterator, Predicate<? super T> predicate)
Deprecated.Returns an iterator with elements from an originaliterator
where the givenpredicate
matches removed.- Type Parameters:
T
-- Parameters:
iterator
-predicate
-- Returns:
-
filterIterator
public static <T> Iterator<T> filterIterator(Iterator<? extends T> iterator, Predicate<? super T> predicate)
Returns an iterator with elements from an originaliterator
where the givenpredicate
matches removed.- Type Parameters:
T
-- Parameters:
iterator
-predicate
-- Returns:
-
transformIterator
public static <S,R> Iterator<R> transformIterator(Iterator<S> iterator, Transformer<S,R> transformer)
Returns an iterator with elements of an originaliterator
transformed by atransformer
.- Type Parameters:
R
-S
-- Parameters:
iterator
-transformer
-- Returns:
-
properties
public static Iterator<Property> properties(PropertyIterator propertyIterator)
Returns an iterator ofProperty
from aPropertyIterator
.- Parameters:
propertyIterator
-- Returns:
-
nodes
public static Iterator<Node> nodes(NodeIterator nodeIterator)
Returns an iterator ofNode
from aNodeIterator
.- Parameters:
nodeIterator
-- Returns:
-
-