Skip to content

Commit 4232450

Browse files
committed
Use @nullable on public *methods* consistently for Guava classes of common.base
(plus StringUtil, given how erratic its null-friendliness is). Of course, nothing is *proving* that these are correct or complete (and probably nothing short of moving to full JSR308ness can?). ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=70026461
1 parent 2929b11 commit 4232450

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

guava/src/com/google/common/base/Defaults.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import java.util.HashMap;
2323
import java.util.Map;
2424

25+
import javax.annotation.Nullable;
26+
2527
/**
2628
* This class provides default values for all Java types, as defined by the JLS.
2729
*
@@ -56,6 +58,7 @@ private static <T> void put(Map<Class<?>, Object> map, Class<T> type, T value) {
5658
* false} for {@code boolean} and {@code '\0'} for {@code char}. For non-primitive types and
5759
* {@code void}, null is returned.
5860
*/
61+
@Nullable
5962
public static <T> T defaultValue(Class<T> type) {
6063
// Primitives.wrap(type).cast(...) would avoid the warning, but we can't use that from here
6164
@SuppressWarnings("unchecked") // the put method enforces this key-value relationship

guava/src/com/google/common/base/FinalizableReferenceQueue.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import java.util.logging.Level;
3131
import java.util.logging.Logger;
3232

33+
import javax.annotation.Nullable;
34+
3335
/**
3436
* A reference queue with an associated background thread that dequeues references and invokes
3537
* {@link FinalizableReference#finalizeReferent()} on them.
@@ -228,6 +230,7 @@ interface FinalizerLoader {
228230
*
229231
* @throws SecurityException if we don't have the appropriate privileges
230232
*/
233+
@Nullable
231234
Class<?> loadFinalizer();
232235
}
233236

guava/src/com/google/common/base/StandardSystemProperty.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import com.google.common.annotations.Beta;
2020
import com.google.common.annotations.GwtIncompatible;
2121

22+
import javax.annotation.Nullable;
23+
2224
/**
2325
* Represents a {@linkplain System#getProperties() standard system property}.
2426
*
@@ -130,6 +132,7 @@ public String key() {
130132
* Returns the current value for this system property by delegating to
131133
* {@link System#getProperty(String)}.
132134
*/
135+
@Nullable
133136
public String value() {
134137
return System.getProperty(key);
135138
}

guava/src/com/google/common/base/Strings.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ public static String nullToEmpty(@Nullable String string) {
5454
* @return {@code string} itself if it is nonempty; {@code null} if it is
5555
* empty or null
5656
*/
57-
public static @Nullable String emptyToNull(@Nullable String string) {
57+
@Nullable
58+
public static String emptyToNull(@Nullable String string) {
5859
return isNullOrEmpty(string) ? null : string;
5960
}
6061

0 commit comments

Comments
 (0)