KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > collections > functors > NotNullPredicate


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.commons.collections.functors;
17
18 import java.io.Serializable JavaDoc;
19
20 import org.apache.commons.collections.Predicate;
21
22 /**
23  * Predicate implementation that returns true if the input is not null.
24  *
25  * @since Commons Collections 3.0
26  * @version $Revision: 1.6 $ $Date: 2004/05/16 11:47:38 $
27  *
28  * @author Stephen Colebourne
29  */

30 public final class NotNullPredicate implements Predicate, Serializable JavaDoc {
31
32     /** Serial version UID */
33     static final long serialVersionUID = 7533784454832764388L;
34     
35     /** Singleton predicate instance */
36     public static final Predicate INSTANCE = new NotNullPredicate();
37
38     /**
39      * Factory returning the singleton instance.
40      *
41      * @return the singleton instance
42      * @since Commons Collections 3.1
43      */

44     public static Predicate getInstance() {
45         return INSTANCE;
46     }
47
48     /**
49      * Restricted constructor.
50      */

51     private NotNullPredicate() {
52         super();
53     }
54
55     /**
56      * Evaluates the predicate returning true if the object does not equal null.
57      *
58      * @param object the object to evaluate
59      * @return true if not null
60      */

61     public boolean evaluate(Object JavaDoc object) {
62         return (object != null);
63     }
64
65 }
66
Popular Tags