1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.collections15.functors.predicate;
17
18 import net.sf.collections15.Predicate;
19
20 import java.io.Serializable;
21
22
23 /***
24 * <code>Predicate</code> implementation that evaluates to <code>true</code> if
25 * the input is not <code>null</code>.
26 *
27 * @author Stephen Colebourne
28 * @author Chris Lambrou (port to Java 5.0)
29 * @since Commons Collections15 1.0
30 */
31 public final class NotNullPredicate <E> implements Predicate<E>, Serializable
32 {
33
34 static final long serialVersionUID = -5388133109486473053L;
35
36 /***
37 * Returns a <code>PredicateInstance</code> which evaluates to
38 * <code>true</code> if the input object is not <code>null</code>.
39 *
40 * @return A <code>PredicateInstance</code> which evaluates to
41 * <code>true</code> if the input object is not <code>null</code>.
42 *
43 * @since Collections15 1.0
44 */
45 public static <T> Predicate<T> getInstance()
46 {
47 return new NotNullPredicate<T>();
48 }
49
50 /***
51 * Creates a new instance.
52 */
53 protected NotNullPredicate()
54 {
55 }
56
57 /***
58 * Evaluates the <code>Predicate</code>, returning <code>true</code> if the
59 * object is not <code>null</code>.
60 *
61 * @param object The object to evaluate.
62 *
63 * @return <code>true</code> if the object is not <code>null</code>.
64 */
65 public boolean evaluate(E object)
66 {
67 return (object != null);
68 }
69
70 }