How do I convert this model to a valid RealmObject?
I’m new to Realm and I want to stick with 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
(I have multiple implementations):
public interface Change {
void performChange();
}
As far as I know, Realm doesn’t support Sets
, so I made the following changes:
- Switch from Set <Change > to
RealmList<Change>
- Make
the ChangeEntry
extensionRealmObject
- Make
the Change
extensionRealmModel
Now when I try to save ChangeEntry
to Realm, I get the following error:
Only concrete Realm classes are allowed in RealmLists. Neither
interfaces nor abstract classes are allowed.
This is self-explanatory.
Is it possible to save this model to Realm and keep Change's
polymorphic interface provided? If yes, what to do?
Thanks in advance.
Solution
Is it possible to save this model to Realm and preserve the polymorphism that the Change interface provides?
Currently not supported because realm does not yet support polymorphism. It is being processed and you can track the progress here
Now you can only use concrete classes.