Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realm model class implementing RealmModel can't extend another class #2643

Closed
jannispl opened this issue Apr 22, 2016 · 1 comment
Closed

Comments

@jannispl
Copy link

jannispl commented Apr 22, 2016

I was planning to have some of my model classes extend an abstract class containing some common properties, however this currently seems impossible:

@RealmClass
open class MyModel(
        @PrimaryKey
        @Required
        open var id: String = "",
) : NetworkModel(), RealmModel
open abstract class NetworkModel
{
    @Ignore
    open var networkFilledFields: Set<String> = HashSet()
}

This part seems to be relevant for this behavior:

if (!parentElement.toString().equals("java.lang.Object") && !parentElement.toString().equals("io.realm.RealmObject")) {

Is there any reason for Realm to assume either Object or RealmObject as parent class?

@beeender
Copy link
Contributor

Realm currently is using byte code manipulation to replace field accessors and using annotation processor to create proxy classes. Enabling RealmObject to extend from the other class/abstract class will increase a bit complexity of Realm. So it is not implemented right now. But I agree it is something we should support.

I will add your comments to #761 and dup/close this issue to that one since they are related.

Thanks a lot for you feedback!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants