Models that extend or implement

593 views
Skip to first unread message

Manuel R. Ciosici

unread,
Nov 7, 2011, 8:17:10 AM11/7/11
to gree...@googlegroups.com
Hello everyone,

I just started using greenDAO.

Is it possible to create models that implement an interface or entends a class? My project has a model class that is supposed to implement Parcelable so I can send it around from one activity to another. I can include most of my custom code inside the KEEP fields, but what can I do about the implements statement?

Thanks,
Manuel R. Ciosici

Markus Junginger

unread,
Nov 7, 2011, 8:47:54 AM11/7/11
to gree...@googlegroups.com
Hi Manuel,

Extending and implementing classes is not implemented yet. It should be done quickly, I'll look into it very soon. Just waited for someone having a need for it... ;)

How about an API like this?
Entity.implements(String ... interfaces)
Entity.extends(String ... classes)

For your use case, you could just pass IDs to activities. That's quite efficient. Besides, implementing Parcelable is annoying. Actually, if more people request, greenDAO could generate everything needed for Parcelable. Should be straight-forward for greenDAO. I created an issue as a reminder: https://github.com/greenrobot/greenDAO/issues/4

Markus.

Manuel Ciosici

unread,
Nov 7, 2011, 8:54:19 AM11/7/11
to gree...@googlegroups.com
Hey Markus,

How about an API like this?
Entity.implements(String ... interfaces)
Entity.extends(String ... classes)
The API you propose sounds good.

For your use case, you could just pass IDs to activities. That's quite efficient. Besides, implementing Parcelable is annoying. Actually, if more people request, greenDAO could generate everything needed for Parcelable. Should be straight-forward for greenDAO. I created an issue as a reminder: https://github.com/greenrobot/greenDAO/issues/4
I started implementing it with passing IDs. I would like thought to be able to use the models with Parcelable for the modularity I can get that way. I can write Activities that know nothing of who holds the dao and the details and just care about getting a model object.

Thanks for taking the issue.

Hope to see you at GDD next week.

Manuel

Markus Junginger

unread,
Nov 7, 2011, 10:33:33 AM11/7/11
to gree...@googlegroups.com
I just pushed a new version to github that allows specifying a superclass and implementing one or more interfaces.

The syntax goes like this:
  entity.setSuperclass("TestSuperclass");
  entity.implementsInterface("TestInterface");
  entity.implementsSerializable(); // Convenience

Thanks for making me finally implement this feature... ;)

Markus

Manuel Ciosici

unread,
Nov 7, 2011, 10:35:04 AM11/7/11
to gree...@googlegroups.com
Thanks,

I will try it tomorrow.

Manuel

Pradeep Kumar Reddy

unread,
Feb 28, 2017, 11:42:25 AM2/28/17
to greenDAO
i want my Entity class to implement an interface.  Where should i write the following  to implement the interface 
 
                      entity.implementsInterface("TestInterface") 
Reply all
Reply to author
Forward
0 new messages