Home | History | Annotate | Download | only in base

Lines Matching refs:Predicate

33  * Contains static factory methods for creating {@code Predicate} instances.
49 * Returns a predicate that always evaluates to {@code true}.
53 public static <T> Predicate<T> alwaysTrue() {
54 return (Predicate<T>) AlwaysTruePredicate.INSTANCE;
58 * Returns a predicate that always evaluates to {@code false}.
62 public static <T> Predicate<T> alwaysFalse() {
63 return (Predicate<T>) AlwaysFalsePredicate.INSTANCE;
67 * Returns a predicate that evaluates to {@code true} if the object reference
71 public static <T> Predicate<T> isNull() {
72 return (Predicate<T>) IsNullPredicate.INSTANCE;
76 * Returns a predicate that evaluates to {@code true} if the object reference
80 public static <T> Predicate<T> notNull() {
81 return (Predicate<T>) NotNullPredicate.INSTANCE;
85 * Returns a predicate that evaluates to {@code true} if the given predicate
88 public static <T> Predicate<T> not(Predicate<T> predicate) {
89 return new NotPredicate<T>(predicate);
93 * Returns a predicate that evaluates to {@code true} if each of its
96 * predicate is found. It defensively copies the iterable passed in, so future
97 * changes to it won't alter the behavior of this predicate. If {@code
98 * components} is empty, the returned predicate will always evaluate to {@code
101 public static <T> Predicate<T> and(
102 Iterable<? extends Predicate<? super T>> components) {
107 * Returns a predicate that evaluates to {@code true} if each of its
110 * predicate is found. It defensively copies the array passed in, so future
111 * changes to it won't alter the behavior of this predicate. If {@code
112 * components} is empty, the returned predicate will always evaluate to {@code
115 public static <T> Predicate<T> and(Predicate<? super T>... components) {
120 * Returns a predicate that evaluates to {@code true} if both of its
123 * predicate is found.
125 public static <T> Predicate<T> and(Predicate<? super T> first,
126 Predicate<? super T> second) {
132 * Returns a predicate that evaluates to {@code true} if any one of its
135 * true predicate is found. It defensively copies the iterable passed in, so
136 * future changes to it won't alter the behavior of this predicate. If {@code
137 * components} is empty, the returned predicate will always evaluate to {@code
140 public static <T> Predicate<T> or(
141 Iterable<? extends Predicate<? super T>> components) {
146 * Returns a predicate that evaluates to {@code true} if any one of its
149 * true predicate is found. It defensively copies the array passed in, so
150 * future changes to it won't alter the behavior of this predicate. If {@code
151 * components} is empty, the returned predicate will always evaluate to {@code
154 public static <T> Predicate<T> or(Predicate<? super T>... components) {
159 * Returns a predicate that evaluates to {@code true} if either of its
162 * true predicate is found.
164 public static <T> Predicate<T> or(Predicate<? super T> first,
165 Predicate<? super T> second) {
171 * Returns a predicate that evaluates to {@code true} if the object being
174 public static <T> Predicate<T> equalTo(@Nullable T target) {
175 // TODO: Change signature to return Predicate<Object>.
182 * Returns a predicate that evaluates to {@code true} if the object being
184 * is {@code null} this predicate evaluates to {@code false}.
191 public static Predicate<Object> instanceOf(Class<?> clazz) {
196 * Returns a predicate that evaluates to {@code true} if the object reference
199 * behavior of the predicate.
207 public static <T> Predicate<T> in(Collection<? extends T> target) {
212 * Returns the composition of a function and a predicate. For every {@code x},
213 * the generated predicate returns {@code predicate(function(x))}.
215 * @return the composition of the provided function and predicate
217 public static <A, B> Predicate<A> compose(
218 Predicate<B> predicate, Function<A, ? extends B> function) {
219 return new CompositionPredicate<A, B>(predicate, function);
224 enum AlwaysTruePredicate implements Predicate<Object> {
237 enum AlwaysFalsePredicate implements Predicate<Object> {
248 /** @see Predicates#not(Predicate) */
250 implements Predicate<T>, Serializable {
251 private final Predicate<T> predicate;
253 private NotPredicate(Predicate<T> predicate) {
254 this.predicate = checkNotNull(predicate);
257 return !predicate.apply(t);
260 return ~predicate.hashCode(); /* Invert all bits. */
265 return predicate.equals(that.predicate);
270 return "Not(" + predicate.toString() + ")";
279 implements Predicate<T>, Serializable {
280 private final Iterable<? extends Predicate<? super T>> components;
282 private AndPredicate(Iterable<? extends Predicate<? super T>> components) {
286 for (Predicate<? super T> predicate : components) {
287 if (!predicate.apply(t)) {
295 for (Predicate<? super T> predicate : components) {
296 result &= predicate.hashCode();
315 implements Predicate<T>, Serializable {
316 private final Iterable<? extends Predicate<? super T>> components;
318 private OrPredicate(Iterable<? extends Predicate<? super T>> components) {
322 for (Predicate<? super T> predicate : components) {
323 if (predicate.apply(t)) {
331 for (Predicate<? super T> predicate : components) {
332 result |= predicate.hashCode();
351 implements Predicate<T>, Serializable {
378 implements Predicate<Object>, Serializable {
405 private enum IsNullPredicate implements Predicate<Object> {
418 private enum NotNullPredicate implements Predicate<Object> {
431 implements Predicate<T>, Serializable {
466 /** @see Predicates#compose(Predicate, Function) */
468 implements Predicate<A>, Serializable {
469 final Predicate<B> p;
472 private CompositionPredicate(Predicate<B> p, Function<A, ? extends B> f) {
495 * predicate(function2(function1(x)))
498 * compose(predicate, compose(function2, function1))
499 * compose(compose(predicate, function2), function1)
539 private static <T> List<Predicate<? super T>> asList(
540 Predicate<? super T> first, Predicate<? super T> second) {
541 return Arrays.<Predicate<? super T>>asList(first, second);