Java Firebase object object serialization and inheritance

Does it also serialize inherited properties?

@IgnoreExtraProperties
public class Item extend BaseObservable {
    private String foo;

    public Item() { }

    @Bindable
    public String getFoo() {
        return this.foo;
    }
}
+4
source share
1 answer

I just ran into the same problem and found your question. Although I could not find a definitive answer elsewhere, some experiments have shown that neither fields publicnor getters are inherited.

Since my base class is abstract, I just made the fields protected and implemented by getters to return them in each subclass. Repetition is not ideal, but my objects are now stored in Firebase with inherited fields.

+7
source

All Articles