    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one or more
    003 * contributor license agreements.  See the NOTICE file distributed with
    004 * this work for additional information regarding copyright ownership.
    005 * The ASF licenses this file to You under the Apache License, Version 2.0
    006 * (the "License"); you may not use this file except in compliance with
    007 * the License.  You may obtain a copy of the License at
    008 *
    009 *      https://www.apache.org/licenses/LICENSE-2.0
    010 *
    011 * Unless required by applicable law or agreed to in writing, software
    012 * distributed under the License is distributed on an "AS IS" BASIS,
    013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014 * See the License for the specific language governing permissions and
    015 * limitations under the License.
    016 */
    017
    018package org.apache.commons.collections4;
    019
    020/**
    021 * Defines a functor interface implemented by classes that perform a predicate test on an object.
    022 * <p>
    023 * A {@code Predicate} is the object equivalent of an {@code if} statement. It uses the input object to return a true or false value, and is often used in
    024 * validation or filtering.
    025 * </p>
    026 * <p>
    027 * Standard implementations of common predicates are provided by {@link PredicateUtils}. These include true, false, instanceof, equals, and, or, not, method
    028 * invocation and null testing.
    029 * </p>
    030 *
    031 * @param <T> The type of the input to the predicate.
    032 * @since 1.0 This will be deprecated in 5.0 in favor of {@link Predicate}.
    033 */
    034//@Deprecated
    035public interface Predicate<T> extends java.util.function.Predicate<T> {
    036
    037    /**
    038     * Use the specified parameter to perform a test that returns true or false.
    039     *
    040     * @param object The object to evaluate, should not be changed.
    041     * @return true or false.
    042     * @throws ClassCastException       (runtime) if the input is the wrong class.
    043     * @throws IllegalArgumentException (runtime) if the input is invalid.
    044     * @throws FunctorException         (runtime) if the predicate encounters a problem.
    045     */
    046    boolean evaluate(T object);
    047
    048    @Override
    049    default boolean test(final T t) {
    050        return evaluate(t);
    051    }
    052}