1993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira/*
2993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * Copyright (C) 2007 Google Inc.
3993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira *
4993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * Licensed under the Apache License, Version 2.0 (the "License");
5993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * you may not use this file except in compliance with the License.
6993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * You may obtain a copy of the License at
7993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira *
8993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * http://www.apache.org/licenses/LICENSE-2.0
9993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira *
10993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * Unless required by applicable law or agreed to in writing, software
11993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * distributed under the License is distributed on an "AS IS" BASIS,
12993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * See the License for the specific language governing permissions and
14993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * limitations under the License.
15993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira */
16993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira
171bdbfefe4b144c7b031a1d9242a0fa061a0ae6b5Scott Kennedypackage com.google.android.mail.common.base;
18993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira
19993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira
20993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira/**
21993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * Determines a true or false value for a given input. For example, a
22993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * {@code RegexPredicate} might implement {@code Predicate<String>}, and return
23993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * {@code true} for any string that matches its given regular expression.
24993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira *
25993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * <p>Implementations which may cause side effects upon evaluation are strongly
26993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * encouraged to state this fact clearly in their API documentation.
27993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira *
28993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * @author Kevin Bourrillion
29993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira * @since 2010.01.04 <b>stable</b> (imported from Google Collections Library)
30993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira */
31993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereirapublic interface Predicate<T> {
32993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira
33993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira  /*
34993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * This interface does not extend Function<T, Boolean> because doing so would
35993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * let predicates return null.
36993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   */
37993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira
38993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira  /**
39993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * Applies this predicate to the given object.
40993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   *
41993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * @param input the input that the predicate should act on
42993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * @return the value of this predicate when applied to the input {@code t}
43993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   */
44993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira  boolean apply(T input);
45993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira
46993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira  /**
47993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * Indicates whether some other object is equal to this {@code Predicate}.
48993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * This method can return {@code true} <i>only</i> if the specified object is
49993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * also a {@code Predicate} and, for every input object {@code input}, it
50993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * returns exactly the same value. Thus, {@code predicate1.equals(predicate2)}
51993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * implies that either {@code predicate1.apply(input)} and
52993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * {@code predicate2.apply(input)} are both {@code true} or both
53993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * {@code false}.
54993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   *
55993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * <p>Note that it is always safe <i>not</i> to override
56993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   * {@link Object#equals}.
57993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira   */
58993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira  boolean equals(Object obj);
59993ef2674bf860a84c5c17e51a7a9e13e5d56504Mindy Pereira}
60