Best practice and how to implement RealmList that need to support different types of objects
- 阅读更多 关于 Best practice and how to implement RealmList that need to support different types of objects
问题 I have a model 'A' that have a list that can be of type 'B' or 'C' and more. I know Polymorphism is not supported by Realm and i cant just do RealmList<RealmObject> or RealmList<? extends RealmObject> . I just can't figure out how to implement this behavior with Realm. 回答1: Polymorphism support is tracked here: https://github.com/realm/realm-java/issues/761 , but as long as it isn't implemented you have to use composition instead (https://en.wikipedia.org/wiki/Composition_over_inheritance) In