Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase java object serialization and Inheritance [duplicate]

Does it also serialize inherited properties?

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

    public Item() { }

    @Bindable
    public String getFoo() {
        return this.foo;
    }
}
like image 768
rocketspacer Avatar asked Mar 13 '23 06:03

rocketspacer


1 Answers

I just ran into the same issue and found your question. While I could not find a definitive answer elsewhere, some experimentation revealed that neither public fields nor getters are inherited.

Since my base class is abstract, I just made the fields protected and implemented getters to return them in each subclass. The repetition isn't ideal, but my objects are now saving in Firebase with the inherited fields.

like image 115
Andy Dyer Avatar answered Mar 18 '23 22:03

Andy Dyer