phax / jcodemodel

A heavily extended fork of the com.sun.codemodel (from 2013/09)
Other
93 stars 34 forks source link

Enum constant arg with class #86

Closed robertomorati closed 3 years ago

robertomorati commented 3 years ago

Hi @phax

I faced with an "unusual" situation, where I need to pass a Class as a parameter in a constant enum. In other words, something like that:

ERRO_SQL("900","System Error", MonitoringKeySQL.class)

I have defined JDefinedClass monitoringKeySQL= createJDefinedClass("package.MonitoringKeySQL");

enums.arg(<class here???>);

Please, could help me with this situation?

All the best,

phax commented 3 years ago

Try cm.ref("package.MonitoringKeySQL").dotClass()

phax commented 3 years ago

What version are you using? With the latest version this my output for the test case:

package issue86;

public class Issue86Test {

    public enum MyEnum {
        A(String.class),
        C(null);
    }
}
robertomorati commented 3 years ago

Hi @pahx.

That's worked. Really sorry, was my mistake, because I migrated from old jcodemodel (org.glassfish.jaxb). I tried to delete my message, but it wasn't fast enough XD

I really appreciate your attention and great job!! All the est!!