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
| 77 | * @author Joel Leitch |
| 78 | */ |
| 79 | public 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 | } |
no outgoing calls
no test coverage detected