agentgt / jirm

A Java Immutable object Relational Mapper focused on simplicity, convenience, and thread safety.
Apache License 2.0
66 stars 10 forks source link

How about using Paranamer instead of annotations (@ConstructorProperties etc)? #1

Closed rponte closed 11 years ago

rponte commented 11 years ago

First off, I saw your e-mail on MyBatis maillist and I think you've done a great work with jirm! I hope Mybatis team gets some ideas from jirm.

If I understood correctly, you said it's not possible to extract parameter names from constructor due to some limitations on JVM, right?

Unfortuanately the JVM has some limitations on reflection of constructor based arguments so you will have to annotate your constructor with either JDK's @ConstructorProperties or Jackson's @JsonCreator and @JsonProperty

I don't know if you already know Paranamer library, but I think you might avoid the necessity of using annotations on constructor if you use it.

Great frameworks like VRaptor has been using Paranamer since the beginning and the result is really great so far. The not use of annotations on constructors and methods becomes the code cleaner.

agentgt commented 11 years ago

Paranamer looks very interesting and I like the idea of a separate component that manages parameters names. I'm sure that there will still be cases where you will need annotations if your using obfuscation but it looks like this library provides a strategy pattern for resolving.

What I'm currently looking into is potentially picking some sort of data DSL for immutable object definition ie something like Protobuf. Or I might look into the very neglected and forgotten about JSR 269 in which case annotations would be a benefit.