MCPcopy
hub / github.com/google/gson / InstanceCreator

Interface InstanceCreator

gson/src/main/java/com/google/gson/InstanceCreator.java:80–93  ·  gson/src/main/java/com/google/gson/InstanceCreator.java::InstanceCreator

This interface is implemented to create instances of a class that does not define a no-args constructor. If you can modify the class, you should instead add a private, or public no-args constructor. However, that is not possible for library classes, such as JDK classes, or a third-party library that

Source from the content-addressed store, hash-verified

78 * @author Joel Leitch
79 */
80public interface InstanceCreator<T> {
81
82 /**
83 * Gson invokes this call-back method during deserialization to create an instance of the
84 * specified type. The fields of the returned instance are overwritten with the data present in
85 * the JSON. Since the prior contents of the object are destroyed and overwritten, do not return
86 * an instance that is useful elsewhere. In particular, do not return a common instance, always
87 * use {@code new} to create a new instance.
88 *
89 * @param type the parameterized T represented as a {@link Type}.
90 * @return a default object instance of type T.
91 */
92 T createInstance(Type type);
93}

Callers 1

constructMethod · 0.65

Implementers 6

ReflectionTesttest-graal-native-image/src/test/java/
MyParameterizedTypeInstanceCreatorgson/src/test/java/com/google/gson/Par
ReflectionAccessFilterTestgson/src/test/java/com/google/gson/fun
StringHolderTypeAdaptergson/src/test/java/com/google/gson/fun
SomeInterfaceInstanceCreatorgson/src/test/java/com/google/gson/fun
ObjectTestgson/src/test/java/com/google/gson/fun

Calls

no outgoing calls

Tested by

no test coverage detected