1

Where can I find the java @NotNull and @Nullable annotations. I looked in the javax.annotations namespace but could not find it.

For example

    public String(@NotNull String whatever){
     //doSomething
     return whatever;
     }

OR

    @Nullable public String( String whatever){
     //doSomething
     return whatever
Chris
  • 21
  • 3

1 Answers1

1

"JSR 305 proposes adding anotations for defect detections, One enhancements proposed in this JSR is a null check annotation, Find Bugs and IntelliJ already provides support for this. When you use the @NotNull annotation you are defining that your code will not except a null parameter, if you were to provide a null parameter, the annotation would throw a RuntimeException. IntelliJ has integrated its use into the IDE, hence at compile time you you can be warned when you are about to assign NULL to a field that has been annotated as @NotNull."

fonte: http://robaustin.wikidot.com/annotations-and-notnull

sbarboza
  • 72
  • 1
  • 8