In Firebase Realtime Database there is support for deserialising objects using GenericTypeIndicator. Can someone shed light on how to do the same with Firestore ?
I have a document snapshot which I want to convert to a POJO which is parametrised.
This is the error it throws when I try to do that
java.lang.RuntimeException: Could not deserialize object. Class com.thesportsbeing.thesportsbeing.screens.festadmin.eventslist.eventadmin.scoring.MatchScore has generic type parameters, please use GenericTypeIndicator instead.
The problem is there is no GenericTypeIndicator in the firestore package, it is present in the realtime-database package. Any workarounds ? or something to get things done would be great.
MyClass is similiar to this
public class MyClass<R extends SomeAbstractClass> {
R someClassWhichExtendsAboveAbstractClass;
}
Here's a discussion of the issue and workarounds: https://github.com/firebase/firebase-android-sdk/issues/222
Easiest way is to declare a subclass of your generic class:
class MyNonGeneric extends MyClass<R> {}
// Usage
snapshot.toObject(MyNonGeneric.class);
Alternatively need get each top level property of the POJO separately and cast it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With