MCPcopy Create free account
hub / github.com/antlr/codebuff / Predicates

Class Predicates

output/java_guava/1.4.18/Predicates.java:43–763  ·  view source on GitHub ↗

Static utility methods pertaining to Predicate instances. All methods returns serializable predicates as long as they're given serializable parameters. See the Guava User Guide article on the use of Predicate<

Source from the content-addressed store, hash-verified

41
42
43@GwtCompatible(emulated = true)
44public final class Predicates {
45
46 private Predicates() {}
47
48 // TODO(kevinb): considering having these implement a VisitablePredicate
49 // interface which specifies an accept(PredicateVisitor) method.
50
51 /**
52 * Returns a predicate that always evaluates to {@code true}.
53 */
54
55 @GwtCompatible(serializable = true)
56 public static <T> Predicate<T> alwaysTrue() {
57 return ObjectPredicate.ALWAYS_TRUE.withNarrowedType();
58 }
59
60 /**
61 * Returns a predicate that always evaluates to {@code false}.
62 */
63
64 @GwtCompatible(serializable = true)
65 public static <T> Predicate<T> alwaysFalse() {
66 return ObjectPredicate.ALWAYS_FALSE.withNarrowedType();
67 }
68
69 /**
70 * Returns a predicate that evaluates to {@code true} if the object reference being tested is
71 * null.
72 */
73
74 @GwtCompatible(serializable = true)
75 public static <T> Predicate<T> isNull() {
76 return ObjectPredicate.IS_NULL.withNarrowedType();
77 }
78
79 /**
80 * Returns a predicate that evaluates to {@code true} if the object reference being tested is not
81 * null.
82 */
83
84 @GwtCompatible(serializable = true)
85 public static <T> Predicate<T> notNull() {
86 return ObjectPredicate.NOT_NULL.withNarrowedType();
87 }
88
89 /**
90 * Returns a predicate that evaluates to {@code true} if the given predicate evaluates to
91 * {@code false}.
92 */
93
94
95 public static <T> Predicate<T> not(Predicate<T> predicate) {
96 return new NotPredicate<T>(predicate);
97 }
98
99 /**
100 * Returns a predicate that evaluates to {@code true} if each of its components evaluates to

Callers

nothing calls this directly

Calls 1

onMethod · 0.95

Tested by

no test coverage detected