The documentation for all the setValue()
methods of DatabaseReference
states:
In addition, you can set instances of your own class into this
location, provided they satisfy the following constraints:
- The class must have a default constructor that takes no arguments
- The class must define public getters for the properties to be assigned.
Properties without a public getter will be set to their default value
when an instance is deserialized.
The model classes defined in the QuickStart sample project do not have getter methods defined. My experiments seem to indicate they are not actually needed. I'm able to successfully store and retrieve instances of classes that have no getter methods defined, just public fields. Is the documentation correct?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…