org.apache.commons.functor.core.collection
Class FilteredIterable<T>

java.lang.Object
  extended by org.apache.commons.functor.core.collection.FilteredIterable<T>
Type Parameters:
T -
All Implemented Interfaces:
Iterable<T>

public class FilteredIterable<T>
extends Object
implements Iterable<T>

Adds a fluent filtering API to any Iterable.

Version:
$Revision: 1076450 $ $Date: 2011-03-03 00:07:04 +0100 (Thu, 03 Mar 2011) $

Method Summary
static
<T> FilteredIterable<T>
empty()
          Get an empty FilteredIterable.
 Iterator<T> iterator()
          
static
<T> FilteredIterable<T>
of(Iterable<T> iterable)
          Get a FilteredIterable of iterable.
 FilteredIterable<T> retain(Class<?>... ofType)
          Retain elements of any of specified types.
<U> FilteredIterable<U>
retain(Class<U> type)
          Retain elements of a given type with type-safety.
 FilteredIterable<T> retain(UnaryPredicate<? super T> predicate)
          Retain only elements matching predicate.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

iterator

public Iterator<T> iterator()

Specified by:
iterator in interface Iterable<T>

toString

public String toString()
Overrides:
toString in class Object

retain

public FilteredIterable<T> retain(UnaryPredicate<? super T> predicate)
Retain only elements matching predicate.

Parameters:
predicate - filter, non-null
Returns:
this, fluently

retain

public <U> FilteredIterable<U> retain(Class<U> type)
Retain elements of a given type with type-safety.

Type Parameters:
U -
Parameters:
type - filter, non-null
Returns:
new FilteredIterable instance that delegates to this

retain

public FilteredIterable<T> retain(Class<?>... ofType)
Retain elements of any of specified types.

Parameters:
ofType - filter, non-null
Returns:
this, fluently

of

public static <T> FilteredIterable<T> of(Iterable<T> iterable)
Get a FilteredIterable of iterable. If wrapped is null, result will also be null. A FilteredIterable argument will be passed back directly; any other argument will be wrapped in a new FilteredIterable object.

Type Parameters:
T -
Parameters:
iterable - wrapped
Returns:
FilteredIterable

empty

public static <T> FilteredIterable<T> empty()
Get an empty FilteredIterable.

Type Parameters:
T -
Returns:
FilteredIterable


Copyright © 2003-2011 The Apache Software Foundation. All Rights Reserved.