You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2003/05/16 16:19:32 UTC

cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections/decorators TypedCollection.java

scolebourne    2003/05/16 07:19:31

  Modified:    collections/src/java/org/apache/commons/collections/decorators
                        TypedCollection.java
  Log:
  Change to use PredicateUtils rather than own Predicate
  
  Revision  Changes    Path
  1.4       +4 -32     jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/TypedCollection.java
  
  Index: TypedCollection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/decorators/TypedCollection.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TypedCollection.java	9 May 2003 16:41:57 -0000	1.3
  +++ TypedCollection.java	16 May 2003 14:19:31 -0000	1.4
  @@ -60,6 +60,7 @@
   import java.util.Collection;
   
   import org.apache.commons.collections.Predicate;
  +import org.apache.commons.collections.PredicateUtils;
   
   /**
    * <code>TypedCollection</code> decorates another <code>Collection</code>
  @@ -105,36 +106,7 @@
        * @throws IllegalArgumentException if type is null
        */
       protected static Predicate getPredicate(Class type) {
  -        return new InstanceofPredicate(type);
  -    }
  -
  -    /**
  -     * <code>Predicate</code> implementation that checks the type of an object.
  -     * This class may eventually be replaced by 
  -     * <code>org.apache.commons.lang.functor.PredicateUtils.instanceofPredicate()</code>.
  -     */
  -    static class InstanceofPredicate implements Predicate {
  -        /** The type to check for */
  -        private final Class type;
  -
  -        /**
  -         * Constructor
  -         */
  -        public InstanceofPredicate(Class type) {
  -            if (type == null) {
  -                throw new IllegalArgumentException("Type must not be null");
  -            }
  -            this.type = type;
  -        }
  -
  -        /**
  -         * Return true if the object is an instanceof the type of the predicate.
  -         * @param object an <code>Object</code>
  -         * @return <code>true</code> if the object is an instanceof the type of the predicate
  -         */
  -        public boolean evaluate(Object object) {
  -            return type.isInstance(object);
  -        }
  +        return PredicateUtils.instanceofPredicate(type);
       }
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org