Using composition as a workaround for inheritance in realm (android)?

Viewed 3393

In my app, I am using realm as a database platform. Realm has been great thus far- super easy to use, make queries, etc.-though, I have two qualms with it that I am trying to work around.

1) Realm does not support inheritance in model object classes which extend RealmObject. - I am wondering if any developers out there have used composition as a workaround to the inheritance issue and if its worked for them. - In other words, say I have a class "car" which extends RealmObject and then I have other classes such as "honda", "toyota", etc. Does it make sense to make separate car objects for each of these which contain either a honda, toyota, etc.?

2) Realm only supports getters and setters in model object classes - My current workaround for this is by creating static methods within the model object classes. - In other words, say I want to modify a honda's color, I would call something such as, Honda.updateColor(honda, blue). - ^ Is this sloppy, or is this essentially the only way to handle such methods.

Really any feedback would be great!

1 Answers
Related