Commits

Micha Kops committed 1654a70

Findbugs @Nullable examples added.

  • Participants
  • Parent commits fc9dbb9

Comments (0)

Files changed (2)

   		<artifactId>functionaljava</artifactId>
   		<version>3.1</version>
   	</dependency>
+  	<dependency>
+  		<groupId>com.google.code.findbugs</groupId>
+  		<artifactId>findbugs</artifactId>
+  		<version>2.0.1</version>
+  	</dependency>
+  	<dependency>
+  		<groupId>com.google.code.findbugs</groupId>
+  		<artifactId>annotations</artifactId>
+  		<version>2.0.1</version>
+  	</dependency>
   </dependencies>
 </project>

src/main/java/com/hascode/tutorial/FindBugsNullMarker.java

+package com.hascode.tutorial;
+
+import javax.annotation.Nullable;
+
+public class FindBugsNullMarker {
+	public static void main(final String[] args) {
+		System.out.println(findTagById(1024l)); // label_400
+		System.out.println(findTagByIdNullAllowed(null)); // ok, we've declared
+															// @Nullable
+		System.out.println(findTagById(null)); // findbugs complains
+	}
+
+	static String findTagById(final Long id) {
+		return "label_" + Long.toHexString(id);
+	}
+
+	static String findTagByIdNullAllowed(@Nullable final Long id) {
+		return findTagById(id);
+	}
+}