Ollie
Ollie copied to clipboard
how to register my TypeAdapter?
public class StringArrayAdapter extends TypeAdapter<ArrayList<String>, String> {
@Override
public String serialize(ArrayList<String> value) {
return new Gson().toJson(value);
}
@Override
public ArrayList<String> deserialize(String value) {
return new Gson().fromJson(value, new TypeToken<ArrayList<String>>(){}.getType());
}
}
How to use it?
use array build failed
Caused by: java.lang.NullPointerException
at ollie.internal.codegen.element.TypeAdapterElement.getDeserializedQualifiedName(TypeAdapterElement.java:69)
at ollie.internal.codegen.Registry.addTypeAdapterModel(Registry.java:91)
at ollie.internal.codegen.step.TypeAdapterStep.process(TypeAdapterStep.java:60)
at ollie.internal.codegen.OllieProcessor.process(OllieProcessor.java:76)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1173)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:859)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
I'm stuck on this issue too. Same exact stacktrace as @liuchenx got. I do have a Model which contains a custom object, I've written the TypeAdapter for it but found no way to associate it with the custom object (which is actually just an enum). I was looking at the source code, trying to understand how the default adapters work, but I couldn't work this out.
Bump. I am running into the same issue as well with no luck looking through the source code. Is support for this not currently implemented @pardom?