mirror of
https://github.com/fankes/moshi.git
synced 2025-10-20 00:19:21 +08:00
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:
committed by
Eric Cochran
parent
8dfe9edc00
commit
2db89355f1
@@ -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);
|
||||
|
Reference in New Issue
Block a user