1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 package org.apache.commons.collections4;
19
20 /**
21 * Defines a functor interface implemented by classes that perform a predicate test on an object.
22 * <p>
23 * 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
24 * validation or filtering.
25 * </p>
26 * <p>
27 * Standard implementations of common predicates are provided by {@link PredicateUtils}. These include true, false, instanceof, equals, and, or, not, method
28 * invocation and null testing.
29 * </p>
30 *
31 * @param <T> The type of the input to the predicate.
32 * @since 1.0 This will be deprecated in 5.0 in favor of {@link Predicate}.
33 */
34 //@Deprecated
35 public interface Predicate<T> extends java.util.function.Predicate<T> {
36
37 /**
38 * Use the specified parameter to perform a test that returns true or false.
39 *
40 * @param object The object to evaluate, should not be changed.
41 * @return true or false.
42 * @throws ClassCastException (runtime) if the input is the wrong class.
43 * @throws IllegalArgumentException (runtime) if the input is invalid.
44 * @throws FunctorException (runtime) if the predicate encounters a problem.
45 */
46 boolean evaluate(T object);
47
48 @Override
49 default boolean test(final T t) {
50 return evaluate(t);
51 }
52 }