shoe shoe - 1 month ago 4
Java Question

Is there any benefit to implementing RealmModel instead of extending RealmObject in Realm?


, in order for an object to be able to be persisted it must either implement
or extend
. Are there benefits to using one over the other?

All it says in the realm docs is:

An alternative to extending the RealmObject base class is implementing the RealmModel interface and adding the @RealmClass annotation.

All methods available on RealmObject are then available through static methods.


Considering that extending any non-RealmObject classes is not possible even if you're implementing RealmModel and adding @RealmClass, in my opinion you just get additional complexity by forcing yourself to use for example RealmObject.isValid(realmObject) instead of realmObject.isValid() that you get naturally for free using extends RealmObject.

So no, you should stick to extending RealmObject. Using implements RealmModel gives you no additional benefit.