Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
315 views
in Technique[技术] by (71.8m points)

android - Are Getter Methods Really Needed for Class Stored Using DatabaseReference.setValue()?

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:

  1. The class must have a default constructor that takes no arguments
  2. 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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...