18b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira/* 28b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * Copyright (C) 2007 Google Inc. 38b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * 48b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * Licensed under the Apache License, Version 2.0 (the "License"); 58b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * you may not use this file except in compliance with the License. 68b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * You may obtain a copy of the License at 78b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * 88b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * http://www.apache.org/licenses/LICENSE-2.0 98b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * 108b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * Unless required by applicable law or agreed to in writing, software 118b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * distributed under the License is distributed on an "AS IS" BASIS, 128b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 138b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * See the License for the specific language governing permissions and 148b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * limitations under the License. 158b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira */ 168b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira 1730e2c24b056542f3b1b438aeb798305d1226d0c8Andy Huangpackage com.android.mail.lib.base; 188b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira 198b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira 208b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira/** 218b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * Determines a true or false value for a given input. For example, a 228b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * {@code RegexPredicate} might implement {@code Predicate<String>}, and return 238b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * {@code true} for any string that matches its given regular expression. 248b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * 258b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * <p>Implementations which may cause side effects upon evaluation are strongly 268b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * encouraged to state this fact clearly in their API documentation. 278b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * 288b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * @author Kevin Bourrillion 298b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * @since 2010.01.04 <b>stable</b> (imported from Google Collections Library) 308b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira */ 318b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereirapublic interface Predicate<T> { 328b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira 338b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira /* 348b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * This interface does not extend Function<T, Boolean> because doing so would 358b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * let predicates return null. 368b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira */ 378b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira 388b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira /** 398b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * Applies this predicate to the given object. 408b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * 418b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * @param input the input that the predicate should act on 428b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * @return the value of this predicate when applied to the input {@code t} 438b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira */ 448b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira boolean apply(T input); 458b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira 468b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira /** 478b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * Indicates whether some other object is equal to this {@code Predicate}. 488b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * This method can return {@code true} <i>only</i> if the specified object is 498b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * also a {@code Predicate} and, for every input object {@code input}, it 508b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * returns exactly the same value. Thus, {@code predicate1.equals(predicate2)} 518b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * implies that either {@code predicate1.apply(input)} and 528b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * {@code predicate2.apply(input)} are both {@code true} or both 538b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * {@code false}. 548b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * 558b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * <p>Note that it is always safe <i>not</i> to override 568b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira * {@link Object#equals}. 578b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira */ 588b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira boolean equals(Object obj); 598b99ba451db6973978e60f91da2199686a9c85e7Mindy Pereira} 60