If an unknown subtype is encountered when decoding:
*
- *
if {@link #withDefaultValue(Object)} is used, then {@code defaultValue} will be returned
- *
if {@link #withFallbackJsonAdapter(JsonAdapter)} is used, then the
- * {@code fallbackJsonAdapter.fromJson(reader)} result will be returned
- *
otherwise a {@link JsonDataException} will be thrown
+ *
If {@link #withDefaultValue(Object)} is used, then {@code defaultValue} will be returned.
+ *
If {@link #withFallbackJsonAdapter(JsonAdapter)} is used, then the
+ * {@code fallbackJsonAdapter.fromJson(reader)} result will be returned.
+ *
Otherwise a {@link JsonDataException} will be thrown.
*
*
*
If an unknown type is encountered when encoding:
*
- *
if {@link #withFallbackJsonAdapter(JsonAdapter)} is used, then the
- * {@code fallbackJsonAdapter.toJson(writer, value)} result will be returned
- *
otherwise a {@link IllegalArgumentException} will be thrown
+ *
If {@link #withFallbackJsonAdapter(JsonAdapter)} is used, then the
+ * {@code fallbackJsonAdapter.toJson(writer, value)} result will be returned.
+ *
Otherwise a {@link IllegalArgumentException} will be thrown.
*
*
*
If the same subtype has multiple labels the first one is used when encoding.
*/
public final class PolymorphicJsonAdapterFactory implements JsonAdapter.Factory {
- /**
- * Thin wrapper around {@link JsonAdapter} to allow {@link PolymorphicJsonAdapter} to
- * distinguish between {@code JsonAdapter} added due to a {@code defaultValue} or added
- * by users of {@link PolymorphicJsonAdapterFactory}.
- */
- private abstract static class DefaultJsonAdapter extends JsonAdapter {
- }
-
final Class baseType;
final String labelKey;
final List labels;
@@ -205,19 +197,15 @@ public final class PolymorphicJsonAdapterFactory implements JsonAdapter.Facto
}
private JsonAdapter