prickle icon indicating copy to clipboard operation
prickle copied to clipboard

Support non-case classes

Open seagullmike opened this issue 7 years ago • 8 comments

It seems regular classes could be supported just as easy, if that is what you need, why not support the same as case classes?

seagullmike avatar Jun 13 '17 18:06 seagullmike

True. Im willing to support regular classes. Do you have a specific need for that functionality now?

benhutchison avatar Jun 14 '17 00:06 benhutchison

I am trying to bind my model classes to a web UI with angular binding, and I get the data from the server in the case classes that are serialized, the problem is that they are immutable and when the model binding happens, the error no setter happens... So I tried to just switch to regular classes, but then that didn't work, so I am trying to not copy manually from one to another, maybe I can accomplish with shapeless, but if prickle worked I wouldn't need to.

seagullmike avatar Jun 14 '17 02:06 seagullmike

BTW you can make case classes mutable by declaring the fields var.

Be aware that this will impact equality, hashcode and thus Map and Set membership logic.

benhutchison avatar Jun 14 '17 03:06 benhutchison

I actually did and it complains about no implicit Prickler

On Tue, Jun 13, 2017 at 10:58 PM, Ben Hutchison [email protected] wrote:

BTW you can make case classes mutable by declaring the fields var.

Be aware that this will impact equality, hashcode and thus Map and Set membership logic.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/benhutchison/prickle/issues/42#issuecomment-308313205, or mute the thread https://github.com/notifications/unsubscribe-auth/AALJuGDqsdmnU3E0MdAaf44MXAMFoq4sks5sD1p1gaJpZM4N46bX .

-- Michael D. McCray (314) 596-AOP1 President - Object Nirvana, Inc. Website: http://www.objectnirvana.com Blog: http://aodbms.blogspot.com Email: [email protected] Skype: seagullmike Twitter: http://twitter.com/MichaelDMcCray GitHub: https://github.com/MichaelDMcCray

seagullmike avatar Jun 14 '17 11:06 seagullmike

There's no casual relationship between those things. I'd need to see a reproducible example to credit that claim.

On 14 Jun 2017 21:46, "Michael D. McCray" [email protected] wrote:

I actually did and it complains about no implicit Prickler

On Tue, Jun 13, 2017 at 10:58 PM, Ben Hutchison [email protected] wrote:

BTW you can make case classes mutable by declaring the fields var.

Be aware that this will impact equality, hashcode and thus Map and Set membership logic.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/benhutchison/prickle/issues/ 42#issuecomment-308313205>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ AALJuGDqsdmnU3E0MdAaf44MXAMFoq4sks5sD1p1gaJpZM4N46bX> .

-- Michael D. McCray (314) 596-AOP1 President - Object Nirvana, Inc. Website: http://www.objectnirvana.com Blog: http://aodbms.blogspot.com Email: [email protected] Skype: seagullmike Twitter: http://twitter.com/MichaelDMcCray GitHub: https://github.com/MichaelDMcCray

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/benhutchison/prickle/issues/42#issuecomment-308406494, or mute the thread https://github.com/notifications/unsubscribe-auth/AAF05Gl-u8p_XpLXaGI2feD16RcLZUV6ks5sD8eOgaJpZM4N46bX .

benhutchison avatar Jun 14 '17 22:06 benhutchison

Ok, I'll try it again and see what the error is and get back to you

On Wed, Jun 14, 2017 at 5:33 PM, Ben Hutchison [email protected] wrote:

There's no casual relationship between those things. I'd need to see a reproducible example to credit that claim.

On 14 Jun 2017 21:46, "Michael D. McCray" [email protected] wrote:

I actually did and it complains about no implicit Prickler

On Tue, Jun 13, 2017 at 10:58 PM, Ben Hutchison < [email protected]> wrote:

BTW you can make case classes mutable by declaring the fields var.

Be aware that this will impact equality, hashcode and thus Map and Set membership logic.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <https://github.com/benhutchison/prickle/issues/ 42#issuecomment-308313205>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ AALJuGDqsdmnU3E0MdAaf44MXAMFoq4sks5sD1p1gaJpZM4N46bX> .

-- Michael D. McCray (314) 596-AOP1 President - Object Nirvana, Inc. Website: http://www.objectnirvana.com Blog: http://aodbms.blogspot.com Email: [email protected] Skype: seagullmike Twitter: http://twitter.com/MichaelDMcCray GitHub: https://github.com/MichaelDMcCray

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/benhutchison/prickle/issues/ 42#issuecomment-308406494>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAF05Gl-u8p_ XpLXaGI2feD16RcLZUV6ks5sD8eOgaJpZM4N46bX>

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/benhutchison/prickle/issues/42#issuecomment-308577123, or mute the thread https://github.com/notifications/unsubscribe-auth/AALJuNtfbo3jPpp8T2gd2XUSDg0PxUaHks5sEF-4gaJpZM4N46bX .

-- Michael D. McCray (314) 596-AOP1 President - Object Nirvana, Inc. Website: http://www.objectnirvana.com Blog: http://aodbms.blogspot.com Email: [email protected] Skype: seagullmike Twitter: http://twitter.com/MichaelDMcCray GitHub: https://github.com/MichaelDMcCray

seagullmike avatar Jun 15 '17 00:06 seagullmike

"If there is a non-case class you wish to pickle that's unsupported out-of-the-box, you can define your own and put them in implicit scope. See prickle.Pickler and prickle.Unpickler for examples."

Does this mean that one can define custom pickler/unpickler code for non-case classes? Could that work for java classes? Can you point to some example of how to write custom pickler/unpickler functionality?

dragonfly-ai avatar Jul 18 '17 04:07 dragonfly-ai

You'd just need to implement the Pickler and Unpickler traits. You can see lots of custom implementations for non-case classes in the library source. You can implement for Java as well.

benhutchison avatar Jul 18 '17 07:07 benhutchison