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

Interface InstanceCreator

src/main/java/com/google/gson/InstanceCreator.java:79–92  ·  view source on GitHub ↗

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

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

Callers 1

constructMethod · 0.65

Implementers 8

MyParameterizedTypeInstanceCreatorsrc/test/java/com/google/gson/Paramter
MyInstanceCreatorsrc/test/java/com/google/gson/MappedOb
StringHolderTypeAdaptersrc/test/java/com/google/gson/function
InstanceCreatorTestsrc/test/java/com/google/gson/function
SomeInterfaceInstanceCreatorsrc/test/java/com/google/gson/function
ObjectTestsrc/test/java/com/google/gson/function
MapTestsrc/test/java/com/google/gson/function
DefaultConstructorCreatorsrc/main/java/com/google/gson/DefaultT

Calls

no outgoing calls

Tested by

no test coverage detected