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