aesteve / nubes

Annotation layer on top of Vert.x 3
Apache License 2.0
120 stars 35 forks source link

User method parameter names instead of requiring @param or pathparam type annotations #48

Closed apatrida closed 8 years ago

apatrida commented 9 years ago

Java 8, Kotlin, and others have parameter name information available for methods. So @Param("from") from: Int us redundant. Vert.x is Java 8 or higher. Although Java 8 requires you compiling with parameter names turned on.

For languages like Kotlin you could have a plugin return the names of parameters for you if you don't want to figure out how to do that. Same plugin model could support Java 8.

Or since you have annotations, you could use annotation processing to write out the property names at compile time to a resources file you use. Another option, although not all other JVM languages might support annotation processing. I think Paranamer does this already, https://github.com/paul-hammant/paranamer.

I note that Jackson JSON processor has support for plugins that do all the models above.

aesteve commented 9 years ago

Thanks a lot.

I'll definitely refactor all the method introspection code using the JDK 8 API next week, and therefore use parameter names if @Param has no string parameter.

@Param(String) should stay, just in case users want to do some tricky stuff. But @Param should rely on parameter's name, you're absolutely right.

aesteve commented 8 years ago

Done