Class FilteredIterable<T>
java.lang.Object
org.apache.commons.functor.core.collection.FilteredIterable<T>
- Type Parameters:
T- the Iterable generic type
- All Implemented Interfaces:
Iterable<T>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final FilteredIterableA defaultFilteredIterablestatic instance that iterates over an empty collection.TheIterablehas to be filtered.The predicate used to test inputIterableelements. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateFilteredIterable(Iterable<? extends T> iterable) Create a new FilteredIterable. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> FilteredIterable<T> empty()Get an empty FilteredIterable.iterator()static <T> FilteredIterable<T> Get aFilteredIterableofiterable.Retain elements of any of specified types.<U> FilteredIterable<U> Retain elements of a given type with type-safety.retain(UnaryPredicate<? super T> predicate) Retain only elements matchingpredicate.toString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
EMPTY
A defaultFilteredIterablestatic instance that iterates over an empty collection. -
iterable
-
predicate
-
-
Constructor Details
-
FilteredIterable
-
-
Method Details
-
iterator
-
toString
-
retain
Retain only elements matchingpredicate.- Parameters:
predicate- filter, non-null- Returns:
this, fluently
-
retain
Retain elements of a given type with type-safety.- Type Parameters:
U- the input Class generic type.- Parameters:
type- filter, non-null- Returns:
- new FilteredIterable instance that delegates to
this
-
retain
Retain elements of any of specified types.- Parameters:
ofType- filter, non-null- Returns:
this, fluently
-
of
Get aFilteredIterableofiterable. Ifwrappedisnull, result will also benull. AFilteredIterableargument will be passed back directly; any other argument will be wrapped in a newFilteredIterableobject.- Type Parameters:
T- the input iterable generic type- Parameters:
iterable- wrapped- Returns:
- FilteredIterable
-
empty
Get an empty FilteredIterable.- Type Parameters:
T- the expectedIterablegeneric type.- Returns:
- FilteredIterable
-