@Retention(value=RUNTIME) @Documented public @interface JsonClass
Modifier and Type | Required Element and Description |
---|---|
boolean |
generateAdapter
True to trigger the annotation processor to generate an adapter for this type.
|
public abstract boolean generateAdapter
There are currently some restrictions on which types that can be used with generated adapters:
generator()
).
public abstract String generator
Requirements for generated adapter class signatures:
JsonAdapter
and be parameterized by this type.
Types.generatedJsonAdapterName(java.lang.Class<?>)
should be used for the fully qualified class name in
order for Moshi to correctly resolve and load the generated JsonAdapter.
Moshi
instance.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.
Copyright © 2019. All rights reserved.