001    // Copyright 2010, 2011 The Apache Software Foundation
002    //
003    // Licensed under the Apache License, Version 2.0 (the "License");
004    // you may not use this file except in compliance with the License.
005    // You may obtain a copy of the License at
006    //
007    // http://www.apache.org/licenses/LICENSE-2.0
008    //
009    // Unless required by applicable law or agreed to in writing, software
010    // distributed under the License is distributed on an "AS IS" BASIS,
011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012    // See the License for the specific language governing permissions and
013    // limitations under the License.
014    
015    package org.apache.tapestry5.func;
016    
017    /**
018     * Used when filtering a collection of objects of a given type; the predicate is passed
019     * each object in turn, and returns true to include the object in the result collection.
020     * <p>
021     * The {@link F} class includes a number of Predicate factory methods.
022     * <p>
023     * This was converted from a abstract base class to an interface in 5.3.
024     * 
025     * @since 5.2.0
026     * @see Flow#filter(Predicate)
027     * @see Flow#remove(Predicate)
028     */
029    public interface Predicate<T>
030    {
031        /**
032         * This method is overridden in subclasses to define which objects the Predicate will accept
033         * and which it will reject.
034         * 
035         * @param element
036         *            the element from the flow to be evaluated by the Predicate
037         */
038        boolean accept(T element);
039    }