made nullSafe wrapper of JsonAdapter optional

This commit is contained in:
testcenter 2016-06-28 09:18:03 +02:00
parent f482f4a1cb
commit 193349f4aa
2 changed files with 4 additions and 1 deletions

View File

@ -94,4 +94,7 @@ public @interface JsonAdapter {
/** Either a {@link TypeAdapter} or {@link TypeAdapterFactory}. */
Class<?> value();
/** false, to be able to handle {@code null} values within the adapter, default value is true. */
boolean nullSafe() default true;
}

View File

@ -73,7 +73,7 @@ public final class JsonAdapterAnnotationTypeAdapterFactory implements TypeAdapte
+ "JsonSerializer or JsonDeserializer reference.");
}
if (typeAdapter != null) {
if (typeAdapter != null && annotation.nullSafe()) {
typeAdapter = typeAdapter.nullSafe();
}