Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to register my TypeAdapter? #49

Open
liuchenx opened this issue Feb 28, 2015 · 3 comments
Open

how to register my TypeAdapter? #49

liuchenx opened this issue Feb 28, 2015 · 3 comments

Comments

@liuchenx
Copy link

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?

@liuchenx
Copy link
Author

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)

@mrz
Copy link

mrz commented Mar 13, 2015

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.

@r0adkll
Copy link

r0adkll commented Apr 12, 2015

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants