View Javadoc
1   package com.github.davidmoten.rx2;
2   
3   import io.reactivex.functions.Predicate;
4   
5   public final class Predicates {
6   
7       private Predicates() {
8           // prevent instantiation
9       }
10  
11      @SuppressWarnings("unchecked")
12      public static <T> Predicate<T> alwaysFalse() {
13          return (Predicate<T>) FalseHolder.INSTANCE;
14      }
15  
16      private static final class FalseHolder {
17          static final Predicate<Object> INSTANCE = new Predicate<Object>() {
18              @Override
19              public boolean test(Object t) throws Exception {
20                  return false;
21              }
22          };
23      }
24  
25      @SuppressWarnings("unchecked")
26      public static <T> Predicate<T> alwaysTrue() {
27          return (Predicate<T>) TrueHolder.INSTANCE;
28      }
29  
30      private static final class TrueHolder {
31          static final Predicate<Object> INSTANCE = new Predicate<Object>() {
32              @Override
33              public boolean test(Object t) throws Exception {
34                  return true;
35              }
36          };
37      }
38  
39  }