peichhorn / lombok-pg

Collection of lombok extensions
http://peichhorn.github.com/lombok-pg/
Other
327 stars 44 forks source link

Bound TypeParam, how to get them right? #132

Closed aalmiray closed 11 years ago

aalmiray commented 11 years ago

Hi there,

Awesome job with this library, it makes it so easy to do naughty things to your Java code ;-)

So here I am trying to build some custom extensions and found myself in a pickle when it comes to TypeParam and its bounds. Here's one method signature I'd like to generate

<M extends griffon.core.GriffonModel, V extends griffon.core.GriffonView, C extends griffon.core.GriffonController> void withMVCGroup(java.lang.String arg0, griffon.core.MVCClosure<M, V, C> arg1)

Using MethodDecl I attach the following TypeParam definitions

TypeParam("M").withBound(Type("griffon.core.GriffonModel"))
TypeParam("V").withBound(Type("griffon.core.GriffonView"))
TypeParam("C").withBound(Type("griffon.core.GriffonController"))

It all appears to be peachy, but when I print out the node before returning from the annotation handler I get this

 @java.lang.SuppressWarnings("all")
 public <M extends /*missing*/, V extends /*missing*/, C extends /*missing*/>void withMVCGroup(final java.lang.String arg0, final griffon.core.MVCClosure<M, V, C> arg1) {
     griffon.util.ApplicationHolder.getApplication().getMvcGroupManager().withMVCGroup(arg0, arg1);
 }

Needless to say I'm stumped. Is there a special way to make TypeParams work with bounds? Also, what about creating types with wildcards, such as

List<? extends griffon.core.GriffonController>

Thanks!

aalmiray commented 11 years ago

Never mind, I was sending the wrong parameter to TypeParam. Also, though there's no sample usage of Wildcard() I discovered this is what I need for the 2nd question. So... nothing to see here. Closing.