Prayansh Srivastava

    Prayansh Srivastava

    1 year ago
    Hi! :android-wave: This might be a dumb question, but is it possible to annotate and auto-generate serializers for a POJO class in a java file? I am trying something like this
    // MainActivity.java
    
    public class MainActivity extends Activity {
    
        @Serializable
        static class Props {
            // my POJO
            int count;
            String name;
        }
    
        @Override
        public void onCreate() {
            super.onCreate();
            Props.serializer() // No such method available
        }
    }
    I am not sure if i am misusing / misunderstanding the API here, so feel free to correct 🙂 Thx!
    Nikky

    Nikky

    1 year ago
    serialization does its magic as a compiler plugin.. so if it is not a in file processed by kotlinc.. the magic does not happen
    why not extract it as a data class into a
    .kt
    file ?
    Prayansh Srivastava

    Prayansh Srivastava

    1 year ago
    yea i think thats probably what i will end up doing, was just wondering if the compiler plugin can work on java files. thx for the answer 🙂