Reputation: 1070
In Realm
, in order for an object to be able to be persisted it must either implement RealmModel
or extend RealmObject
. 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.
Upvotes: 12
Views: 3522
Reputation: 81539
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.
Upvotes: 10