KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > ba > npe > NonNullReturnValueAnnotationChecker


1 package edu.umd.cs.findbugs.ba.npe;
2
3 import edu.umd.cs.findbugs.SystemProperties;
4 import edu.umd.cs.findbugs.ba.JavaClassAndMethod;
5 import edu.umd.cs.findbugs.ba.JavaClassAndMethodChooser;
6 import edu.umd.cs.findbugs.ba.XMethod;
7
8 /**
9  * This callback can be passed to Hierarchy.findInvocationLeastUpperBound
10  * to find the @NonNull or @CheckForNull method return value annotation
11  * which should be applied at a call site.
12  *
13  * @author David Hovemeyer
14  * @deprecated
15  */

16 public class NonNullReturnValueAnnotationChecker implements JavaClassAndMethodChooser {
17     private static final boolean DEBUG = SystemProperties.getBoolean("fnd.debug.nullreturn");
18     
19     private MayReturnNullPropertyDatabase database;
20     private JavaClassAndMethod annotatedMethod;
21     private Boolean JavaDoc property;
22
23     /** @deprecated */
24     public NonNullReturnValueAnnotationChecker(MayReturnNullPropertyDatabase database) {
25         this.database = database;
26     }
27     
28     public Boolean JavaDoc getProperty() {
29         return property;
30     }
31     
32     public JavaClassAndMethod getAnnotatedMethod() {
33         return annotatedMethod;
34     }
35     
36     public boolean choose(JavaClassAndMethod javaClassAndMethod) {
37         XMethod xmethod = javaClassAndMethod.toXMethod();
38         if (DEBUG) {
39             System.out.print("Checking " + xmethod + " for @NonNull or @CheckForNull...");
40         }
41         Boolean JavaDoc prop = database.getProperty(xmethod);
42         if (prop != null) {
43             this.property = prop;
44             this.annotatedMethod = javaClassAndMethod;
45             if (DEBUG) {
46                 System.out.println(prop.booleanValue() ? "@CheckForNull" : "@NonNull");
47             }
48             return true;
49         }
50         if (DEBUG) {
51             System.out.println("not found");
52         }
53         return false;
54     }
55 }
56
Popular Tags