Author: limpbizkit
Date: Fri Jun 5 10:51:17 2009
New Revision: 997
Modified:
wiki/UseNullable.wiki
Log:
Edited wiki page through web user interface.
Modified: wiki/UseNullable.wiki
==============================================================================
--- wiki/UseNullable.wiki (original)
+++ wiki/UseNullable.wiki Fri Jun 5 10:51:17 2009
@@ -1,10 +1,10 @@
=Use @Nullable=
To eliminate `NullPointerExceptions` in your codebase, you must be
disciplined about null references. We've been successful at this by
following and enforcing a simple rule:
_Every parameter is non-null unless explicitly specified._
-The [http://code.google.com/p/google-collections/ Google Collections
library] has simple APIs to get a nulls under control.
`Preconditions.checkNotNull` can be used to fast-fail if a null reference
is found, and `...@nullable` can be used to annotate a parameter that permits
the `null` value:
+The [http://code.google.com/p/google-collections/ Google Collections
library] and [http://code.google.com/p/jsr-305/ JSR-305] have simple APIs
to get a nulls under control. `Preconditions.checkNotNull` can be used to
fast-fail if a null reference is found, and `...@nullable` can be used to
annotate a parameter that permits the `null` value:
{{{
-import static com.google.common.base.Nullable;
import static com.google.common.base.Preconditions.checkNotNull;
+import static javax.annotation.Nullable;
public class Person {
...
@@ -15,4 +15,4 @@
this.phone = phone;
}
}}}
-*Guice forbids null by default.* It will refuse to inject `null`, failing
with a `ProvisionException` instead. If `null` is permissible by your
class, you can annotate the field or parameter with `...@nullable`. Guice
recognizes any `...@nullable` annotation, like
[http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/base/Nullable.html
com.google.common.base.Nullable] or
[http://code.google.com/p/jsr-305/source/browse/trunk/ri/src/main/java/javax/annotation/Nullable.java?r=24
javax.annotation.Nullable].
+*Guice forbids null by default.* It will refuse to inject `null`, failing
with a `ProvisionException` instead. If `null` is permissible by your
class, you can annotate the field or parameter with `...@nullable`. Guice
recognizes any `...@nullable` annotation, like
[http://findbugs.sourceforge.net/api/edu/umd/cs/findbugs/annotations/Nullable.html
edu.umd.cs.findbugs.annotations.Nullable] or
[http://code.google.com/p/jsr-305/source/browse/trunk/ri/src/main/java/javax/annotation/Nullable.java?r=24
javax.annotation.Nullable].
\ No newline at end of file
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"google-guice-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-guice-dev?hl=en
-~----------~----~----~----~------~----~------~--~---