View Javadoc
1   package org.andromda.metafacades.uml;
2   
3   import java.util.ArrayList;
4   import java.util.Collection;
5   import org.apache.commons.collections.CollectionUtils;
6   import org.apache.commons.collections.Predicate;
7   
8   /**
9    * Filters a collection of objects so that the collection contains only those
10   * objects that pass the <code>evaluate</code> test. <p/> It is useful for
11   * filtering the results of a query.
12   * </p>
13   *
14   * @author Anthony Mowers
15   * @author Chad Brandon
16   * @param <T> Type within the Collection
17   */
18  public abstract class FilteredCollection<T>
19      extends ArrayList<T>
20      implements Predicate
21  {
22      /**
23       * Constructor for the FilterCollection object
24       *
25       * @param collection
26       */
27      public FilteredCollection(Collection<T> collection)
28      {
29          this.addAll(collection);
30          CollectionUtils.filter(
31              this,
32              this);
33      }
34  
35      /**
36       * @see org.apache.commons.collections.Predicate#evaluate(Object)
37       */
38      public abstract boolean evaluate(Object object);
39  }