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