[英]com.sun.istack.internal.Nullable Annotation and Guice
When Guice says that it recognizes any @Nullable annotation here ( http://code.google.com/p/google-guice/wiki/UseNullable ) does that mean I can use com.sun.istack.internal.Nullable provided by the Java 7 Runtime successfully? 当Guice说它可以识别此处的任何@Nullable注解( http://code.google.com/p/google-guice/wiki/UseNullable )时,这意味着我可以使用com.sun.istack.internal.Nullable Java 7 Runtime成功?
The fact that the package name is com.sun.istack.internal leads me to believe that I probably shouldn't be using it, but it is pretty convenient to use... 软件包名称为com.sun.istack.internal的事实使我相信我可能不应该使用它,但是使用起来非常方便。
You have to use Nullable
from javax.annotation
package as the example from the site says. 您必须使用
javax.annotation
包中的Nullable
作为站点上的示例。
If you check comments on the site, there are links to proper jar library. 如果您在网站上查看评论,则有指向正确的jar库的链接。
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
In my case I was about to use Nullable annotation from IntelliJ package. 就我而言,我将要使用IntelliJ包中的Nullable注释。 :)
:)
If null is permissible by your class, you can annotate the field or parameter with @Nullable.
如果类允许使用null,则可以使用@Nullable注释字段或参数。 Guice recognizes any @Nullable annotation, like edu.umd.cs.findbugs.annotations.Nullable or javax.annotation.Nullable .
Guice可以识别任何@Nullable批注,例如edu.umd.cs.findbugs.annotations.Nullable或javax.annotation.Nullable 。 —from the Guice site
—来自Guice网站
To confirm chrylis 's hunch above, Guice simply tests the name of the class . 为了确认chrylis的直觉,Guice只需测试类的名称 。
// from core/src/com/google/inject/internal/Nullability.java
if ("Nullable".equals(type.getSimpleName())) {
return true;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.