org.qi4j.functional

## Class ForEach<T>

- java.lang.Object
- - org.qi4j.functional.ForEach<T>

- All Implemented Interfaces:
    Iterable<T>

      public final class ForEach<T>
      extends Object
      implements Iterable<T>

  When using Iterables with map() and filter() the code often reads "in reverse", with the first item last in the code. Example: Iterables.map(function,Iterables.filter(specification, iterable))

  This ForEach class reverses that order and makes the code more readable, and allows easy application of visitors on iterables.

  Example: forEach(iterable).filter(specification).map(function).visit(visitor)

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ForEach(Iterable<T> iterable)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `ForEach<T>` | `filter(Specification<? super T> specification)`
    `<TO> ForEach<TO>` | `flatten()`
    `static <T> ForEach<T>` | `forEach(Iterable<T> iterable)`
    `Iterator<T>` | `iterator()`
    `T` | `last()`
    `<TO> ForEach<TO>` | `map(Function<?,TO> function)`
    `<ThrowableType extends Throwable> boolean` | `visit(Visitor<T,ThrowableType> visitor)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ForEach

          public ForEach(Iterable<T> iterable)

  - ### Method Detail

    - #### forEach

          public static <T> ForEach<T> forEach(Iterable<T> iterable)

    - #### iterator

          public Iterator<T> iterator()

      Specified by:
        `iterator` in interface `Iterable<T>`

    - #### filter

          public ForEach<T> filter(Specification<? super T> specification)

    - #### map

          public <TO> ForEach<TO> map(Function<?,TO> function)

    - #### flatten

          public <TO> ForEach<TO> flatten()

    - #### last

          public T last()

    - #### visit

          public <ThrowableType extends Throwable> boolean visit(Visitor<T,ThrowableType> visitor)
                        throws ThrowableType extends Throwable

      Throws:
        `ThrowableType extends Throwable`