Developer Notes: Apache Commons FilterIterator
Filtering the collection based on the criteria is a great advantage of FilterIterator. package com.blogspot.ojitha.commonexamples; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.apache.commons.collections.Predicate; import org.apache.commons.collections.iterators.FilterIterator; public class ListFilteringExample { /** * @param args */ public static void main(String[] args) { Person a = new Person("Smith", "Wills"); a.setAge(39); Person b = new Person("Kris", "Torano"); b.setAge(15); Person c = new Person("Mark","Anthony"); c.setAge(25); Person d = new Person("Mad", "Max"); d.setAge(19); List<Person> persons = new ArrayList<Person>(); persons.add(a); persons.add(b); persons.add(c); persons.add(d); Predicate predicate = new AdultFilter(18); Iterator<Person> adults = new FilterIterator(persons.iterator()...