The JavaDoc is now more accurate about the type adapter serialization and deserialization (#1441)

This commit is contained in:
Lyubomyr Shaydariv 2019-10-29 01:11:15 +02:00 committed by inder123
parent 87b1d26d06
commit 47b28d99a1

View File

@ -120,6 +120,18 @@ import com.google.gson.stream.JsonWriter;
* .registerSubtype(Circle.class) * .registerSubtype(Circle.class)
* .registerSubtype(Diamond.class); * .registerSubtype(Diamond.class);
* }</pre> * }</pre>
*
* <h3>Serialization and deserialization</h3>
* In order to serialize and deserialize a polymorphic object,
* you must specify the base type explicitly.
* <pre> {@code
* Diamond diamond = new Diamond();
* String json = gson.toJson(diamond, Shape.class);
* }</pre>
* And then:
* <pre> {@code
* Shape shape = gson.fromJson(json, Shape.class);
* }</pre>
*/ */
public final class RuntimeTypeAdapterFactory<T> implements TypeAdapterFactory { public final class RuntimeTypeAdapterFactory<T> implements TypeAdapterFactory {
private final Class<?> baseType; private final Class<?> baseType;