I'm pretty new to Realm and i'd like to persist the following model:
public class ChangeEntry {
private int id;
private long time;
private boolean active;
private Set<Change> changes;
// getters and setters
}
Change is an interface (which i have multiple implementations for):
public interface Change {
void performChange();
}
As i understand Realm does not support Set, so i carried out the following changes:
Set<Change> to RealmList<Change>ChangeEntry extend RealmObjectChange extend RealmModelNow when i try to save a ChangeEntry to Realm, i get the following error:
Only concrete Realm classes are allowed in RealmLists. Neither interfaces nor abstract classes are allowed.
Which is quite self-explanatory.
Is it possible to save this model to Realm and preserve the polymorphism that the Change interface provides? If so, how?
Thanks in advance.
Is it possible to save this model to Realm and preserve the polymorphism that the Change interface provides?
Currently no, as realm does not yet support polymorphism. It is being worked on though, and you can track the progress here.
For now you have to use only concrete classes.
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