Add CheckReturnValue for toJson's string result.

This helps Error Prone and the IDE find accidental usages of toJson(value) instead of toJson(writer, value).
This commit is contained in:
Eric Cochran
2017-09-25 13:05:36 -04:00
committed by Eric Cochran
parent 8dfe9edc00
commit 2db89355f1

View File

@@ -20,6 +20,7 @@ import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.util.Set;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;
import okio.Buffer;
import okio.BufferedSink;
@@ -46,7 +47,7 @@ public abstract class JsonAdapter<T> {
toJson(writer, value);
}
public final String toJson(@Nullable T value) {
public final @CheckReturnValue String toJson(@Nullable T value) {
Buffer buffer = new Buffer();
try {
toJson(buffer, value);