generator
An optional custom generator tag used to indicate which generator should be used. If empty, Moshi's annotation processor will generate an adapter for the annotated type. If not empty, Moshi's processor will skip it and defer to a custom generator. This can be used to allow other custom code generation tools to run and still allow Moshi to read their generated JsonAdapter outputs.
Requirements for generated adapter class signatures:
- The generated adapter must subclass JsonAdapter and be parameterized by this type.
- generatedJsonAdapterName should be used for the fully qualified class name in order for Moshi to correctly resolve and load the generated JsonAdapter.
- The first parameter must be a Moshi instance.
- If generic, a second Type[] parameter should be declared to accept type arguments.
Example for a class "CustomType":
class CustomTypeJsonAdapter(moshi: Moshi, types: Array<Type>) : JsonAdapter<CustomType>() {
// ...
}
To help ensure your own generator meets requirements above, you can use Moshi’s built-in generator to create the API signature to get started, then make your own generator match that expected signature.