| Modifier and Type | Class and Description |
|---|---|
| public abstract static class | ReflectiveTypeAdapterFactory.
type of objects that this Adapter creates. T, type of accumulator used to build the deserialization result. A>Base class for Adapters produced by this factory. |
| pack-priv abstract static class | |
| private static class | |
| private static class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final ConstructorConstructor | |
| private final Excluder | |
| private final FieldNamingStrategy | |
| private final JsonAdapterAnnotationTypeAdapterFactory | |
| private final List |
| Access | Constructor and Description |
|---|---|
| public | ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor, FieldNamingStrategy fieldNamingPolicy, Excluder excluder, JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory, List<ReflectionAccessFilter> reflectionFilters)
|
| Modifier and Type | Method and Description |
|---|---|
| private static <M extends AccessibleObject & Member> void | |
| public <T> TypeAdapter | create(Gson gson, TypeToken<T> type)
Implements com. Returns a type adapter for |
| private ReflectiveTypeAdapterFactory. | |
| private static IllegalArgumentException | createDuplicateFieldException(Class<?> declaringType, String duplicateName, Field field1, Field field2)
|
| private ReflectiveTypeAdapterFactory. | getBoundFields(Gson context, TypeToken<?> type, Class<?> raw, boolean blockInaccessible, boolean isRecord)
|
| private List | |
| private boolean |
| constructorConstructor | back to summary |
|---|---|
| private final ConstructorConstructor constructorConstructor | |
| excluder | back to summary |
|---|---|
| private final Excluder excluder | |
| fieldNamingPolicy | back to summary |
|---|---|
| private final FieldNamingStrategy fieldNamingPolicy | |
| jsonAdapterFactory | back to summary |
|---|---|
| private final JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory | |
| reflectionFilters | back to summary |
|---|---|
| private final List<ReflectionAccessFilter> reflectionFilters | |
| ReflectiveTypeAdapterFactory | back to summary |
|---|---|
| public ReflectiveTypeAdapterFactory(ConstructorConstructor constructorConstructor, FieldNamingStrategy fieldNamingPolicy, Excluder excluder, JsonAdapterAnnotationTypeAdapterFactory jsonAdapterFactory, List<ReflectionAccessFilter> reflectionFilters) | |
| checkAccessible | back to summary |
|---|---|
| private static <M extends AccessibleObject & Member> void checkAccessible(Object object, M member) | |
| create | back to summary |
|---|---|
| public <T> TypeAdapter Implements com. Doc from com. Returns a type adapter for
| |
| createBoundField | back to summary |
|---|---|
| private ReflectiveTypeAdapterFactory. | |
| createDuplicateFieldException | back to summary |
|---|---|
| private static IllegalArgumentException createDuplicateFieldException(Class<?> declaringType, String duplicateName, Field field1, Field field2) | |
| getBoundFields | back to summary |
|---|---|
| private ReflectiveTypeAdapterFactory. | |
| getFieldNames | back to summary |
|---|---|
| private List first element holds the default name
| |
| includeField | back to summary |
|---|---|
| private boolean includeField(Field f, boolean serialize) | |
The RecordAdapter is a special case to handle records for JVMs that support it, for
all other types we use the FieldReflectionAdapter. This class encapsulates the common
logic for serialization and deserialization. During deserialization, we construct an
accumulator A, which we use to accumulate values from the source JSON. After the object has
been read in full, the finalize(Object) method is used to convert the accumulator to
an instance of T.
| Modifier and Type | Field and Description |
|---|---|
| private final ReflectiveTypeAdapterFactory. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv abstract A | |
| pack-priv abstract T | |
| public T | read(JsonReader in)
Implements abstract com. Reads one JSON value (an array, object, string, number, boolean or null) and converts it to a Java object. |
| pack-priv abstract void | readField(A accumulator, JsonReader in, ReflectiveTypeAdapterFactory.
Read a single BoundField into the accumulator. |
| public void | write(JsonWriter out, T value)
Implements abstract com. Writes one JSON value (an array, object, string, number, boolean or null) for |
| fieldsData | back to summary |
|---|---|
| private final ReflectiveTypeAdapterFactory. | |
| Adapter | back to summary |
|---|---|
| pack-priv Adapter(ReflectiveTypeAdapterFactory. | |
| createAccumulator | back to summary |
|---|---|
| pack-priv abstract A createAccumulator() Create the Object that will be used to collect each field value | |
| finalize | back to summary |
|---|---|
| pack-priv abstract T finalize(A accumulator) Convert the accumulator to a final instance of T. | |
| read | back to summary |
|---|---|
| public T read(JsonReader in) throws IOException Implements abstract com. Doc from com. Reads one JSON value (an array, object, string, number, boolean or null) and converts it to a Java object. Returns the converted object.
| |
| readField | back to summary |
|---|---|
| pack-priv abstract void readField(A accumulator, JsonReader in, ReflectiveTypeAdapterFactory. Read a single BoundField into the accumulator. The JsonReader will be pointed at the start of the value for the BoundField to read from. | |
| write | back to summary |
|---|---|
| public void write(JsonWriter out, T value) throws IOException Implements abstract com. Doc from com. Writes one JSON value (an array, object, string, number, boolean or null) for
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final Field | |
| pack-priv final String | fieldName
Name of the underlying field |
| pack-priv final String | serializedName
Name used for serialization (but not for deserialization) |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv abstract void | readIntoArray(JsonReader reader, int index, Object[] target)
Read the value into the target array, used to provide constructor arguments for records |
| pack-priv abstract void | readIntoField(JsonReader reader, Object target)
Read the value from the reader, and set it on the corresponding field on target via reflection |
| pack-priv abstract void | write(JsonWriter writer, Object source)
Read this field value from the source, and append its JSON value to the writer |
| field | back to summary |
|---|---|
| pack-priv final Field field | |
| fieldName | back to summary |
|---|---|
| pack-priv final String fieldName Name of the underlying field | |
| serializedName | back to summary |
|---|---|
| pack-priv final String serializedName Name used for serialization (but not for deserialization) | |
| BoundField | back to summary |
|---|---|
| protected BoundField(String serializedName, Field field) | |
| readIntoArray | back to summary |
|---|---|
| pack-priv abstract void readIntoArray(JsonReader reader, int index, Object[] target) throws IOException, JsonParseException Read the value into the target array, used to provide constructor arguments for records | |
| readIntoField | back to summary |
|---|---|
| pack-priv abstract void readIntoField(JsonReader reader, Object target) throws IOException, IllegalAccessException Read the value from the reader, and set it on the corresponding field on target via reflection | |
| write | back to summary |
|---|---|
| pack-priv abstract void write(JsonWriter writer, Object source) throws IOException, IllegalAccessException Read this field value from the source, and append its JSON value to the writer | |
| Modifier and Type | Field and Description |
|---|---|
| private final ObjectConstructor |
| Access | Constructor and Description |
|---|---|
| pack-priv | FieldReflectionAdapter(ObjectConstructor<T> constructor, ReflectiveTypeAdapterFactory.
|
| Modifier and Type | Method and Description |
|---|---|
| pack-priv T | createAccumulator()
Implements abstract com. Create the Object that will be used to collect each field value |
| pack-priv T | finalize(T accumulator)
Implements abstract com. Convert the accumulator to a final instance of T. |
| pack-priv void | readField(T accumulator, JsonReader in, ReflectiveTypeAdapterFactory.
Implements abstract com. Read a single BoundField into the accumulator. |
| constructor | back to summary |
|---|---|
| private final ObjectConstructor<T> constructor | |
| FieldReflectionAdapter | back to summary |
|---|---|
| pack-priv FieldReflectionAdapter(ObjectConstructor<T> constructor, ReflectiveTypeAdapterFactory. | |
| createAccumulator | back to summary |
|---|---|
| pack-priv T createAccumulator() Implements abstract com. Doc from com. Create the Object that will be used to collect each field value
| |
| finalize | back to summary |
|---|---|
| pack-priv T finalize(T accumulator) Implements abstract com. Doc from com. Convert the accumulator to a final instance of T.
| |
| readField | back to summary |
|---|---|
| pack-priv void readField(T accumulator, JsonReader in, ReflectiveTypeAdapterFactory. Implements abstract com. Doc from com. Read a single BoundField into the accumulator. The JsonReader will be pointed at the start of the value for the BoundField to read from.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final Map | deserializedFields
Maps from JSON member name to field |
| pack-priv static final ReflectiveTypeAdapterFactory. | |
| pack-priv final List |
| Access | Constructor and Description |
|---|---|
| pack-priv | FieldsData(Map<String, ReflectiveTypeAdapterFactory.
|
| deserializedFields | back to summary |
|---|---|
| pack-priv final Map<String, ReflectiveTypeAdapterFactory. Maps from JSON member name to field | |
| EMPTY | back to summary |
|---|---|
| pack-priv static final ReflectiveTypeAdapterFactory. | |
| serializedFields | back to summary |
|---|---|
| pack-priv final List<ReflectiveTypeAdapterFactory. | |
| FieldsData | back to summary |
|---|---|
| pack-priv FieldsData(Map<String, ReflectiveTypeAdapterFactory. | |
| Modifier and Type | Field and Description |
|---|---|
| private final Map | |
| private final Constructor | |
| private final Object[] | |
| pack-priv static final Map |
| Access | Constructor and Description |
|---|---|
| pack-priv | RecordAdapter(Class<T> raw, ReflectiveTypeAdapterFactory.
|
| Modifier and Type | Method and Description |
|---|---|
| pack-priv Object[] | createAccumulator()
Implements abstract com. Create the Object that will be used to collect each field value |
| pack-priv T | finalize(Object[] accumulator)
Implements abstract com. Convert the accumulator to a final instance of T. |
| private static Map | |
| pack-priv void | readField(Object[] accumulator, JsonReader in, ReflectiveTypeAdapterFactory.
Implements abstract com. Read a single BoundField into the accumulator. |
| componentIndices | back to summary |
|---|---|
| private final Map<String, Integer> componentIndices | |
| constructor | back to summary |
|---|---|
| private final Constructor<T> constructor | |
| constructorArgsDefaults | back to summary |
|---|---|
| private final Object[] constructorArgsDefaults | |
| PRIMITIVE_DEFAULTS | back to summary |
|---|---|
| pack-priv static final Map<Class<?>, Object> PRIMITIVE_DEFAULTS | |
| RecordAdapter | back to summary |
|---|---|
| pack-priv RecordAdapter(Class<T> raw, ReflectiveTypeAdapterFactory. | |
| createAccumulator | back to summary |
|---|---|
| pack-priv Object[] createAccumulator() Implements abstract com. Doc from com. Create the Object that will be used to collect each field value
| |
| finalize | back to summary |
|---|---|
| pack-priv T finalize(Object[] accumulator) Implements abstract com. Doc from com. Convert the accumulator to a final instance of T.
| |
| primitiveDefaults | back to summary |
|---|---|
| private static Map | |
| readField | back to summary |
|---|---|
| pack-priv void readField(Object[] accumulator, JsonReader in, ReflectiveTypeAdapterFactory. Implements abstract com. Doc from com. Read a single BoundField into the accumulator. The JsonReader will be pointed at the start of the value for the BoundField to read from.
| |