org.qi4j.api.util
Class Iterables

java.lang.Object
  extended by org.qi4j.api.util.Iterables

public class Iterables
extends Object

Utility methods for working with Iterables. See test for examples of how to use.


Constructor Summary
Iterables()
           
 
Method Summary
static
<T,C extends Collection<T>>
C
addAll(C collection, Iterable<? extends T> iterable)
           
static long count(Iterable<?> iterable)
           
static
<X> Iterable<X>
filter(Specification<? super X> specification, Iterable<X> i)
           
static
<X> X
first(Iterable<? extends X> i)
           
static
<X,I extends Iterable<? extends X>>
Iterable<X>
flatten(I... multiIterator)
           
static
<X,I extends Iterable<? extends X>>
Iterable<X>
flattenIterables(Iterable<I> multiIterator)
           
static
<FROM,TO> TO
fold(Function<? super FROM,TO> function, Iterable<? extends FROM> i)
           
static
<T,C extends T>
Iterable<T>
iterable(C... items)
           
static
<T> Iterable<T>
iterable(Enumeration<T> enumeration)
           
static
<X> X
last(Iterable<? extends X> i)
           
static
<FROM,TO> Iterable<TO>
map(Function<? super FROM,TO> function, Iterable<FROM> from)
           
static
<T> boolean
matchesAll(Specification<? super T> specification, Iterable<T> iterable)
           
static
<T> boolean
matchesAny(Specification<? super T> specification, Iterable<T> iterable)
           
static
<X> Iterable<X>
reverse(Iterable<X> iterable)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Iterables

public Iterables()
Method Detail

addAll

public static <T,C extends Collection<T>> C addAll(C collection,
                                                   Iterable<? extends T> iterable)

count

public static long count(Iterable<?> iterable)

filter

public static <X> Iterable<X> filter(Specification<? super X> specification,
                                     Iterable<X> i)

first

public static <X> X first(Iterable<? extends X> i)

last

public static <X> X last(Iterable<? extends X> i)

reverse

public static <X> Iterable<X> reverse(Iterable<X> iterable)

matchesAny

public static <T> boolean matchesAny(Specification<? super T> specification,
                                     Iterable<T> iterable)

matchesAll

public static <T> boolean matchesAll(Specification<? super T> specification,
                                     Iterable<T> iterable)

flatten

public static <X,I extends Iterable<? extends X>> Iterable<X> flatten(I... multiIterator)

flattenIterables

public static <X,I extends Iterable<? extends X>> Iterable<X> flattenIterables(Iterable<I> multiIterator)

map

public static <FROM,TO> Iterable<TO> map(Function<? super FROM,TO> function,
                                         Iterable<FROM> from)

iterable

public static <T> Iterable<T> iterable(Enumeration<T> enumeration)

iterable

public static <T,C extends T> Iterable<T> iterable(C... items)

fold

public static <FROM,TO> TO fold(Function<? super FROM,TO> function,
                                Iterable<? extends FROM> i)