users@codemodel.java.net

Re: Annotation Param: Using external enumerations as value

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Sun, 12 Sep 2010 10:48:56 +0200

Hi,

>> You need either Enum instance or JEnumConstant (which you can only
>> produce for JDefinedClass at the moment). So if you don't have the
>> class of your enum and it's not a generated class - then you can only
>> accomplish your task by hacking at the moment.
>
> I guess with hacking, you mean modifying the codemodel code. It would
> be nice to be able to create an enum ref.

I meant reflected access to JAnnotationUse.addValue(...)

> For now I could use the solution suggested in the thread "Annotation:
> Parameter and public static final field".
> I would use JAnnotationUse.param(String name, JExpression value) using
> JExpr.direct("Enum.VALUE") but it seems its not in the repository yet.

I was waiting for the issue, I'll commit it now. By the way, I'd
rather use codeModel.ref("com.acme.Enum").fieldRef("VALUE") than
direct expressions.

> BTW: Is the current snapshot available via Maven?

Yes, from the Sonatype repo:

https://oss.sonatype.org/content/repositories/snapshots/com/sun/codemodel/

Here's coninuous integration:

http://hudson.highsource.org/view/codemodel/job/codemodel-trunk-1.5/

Bye.
/lexi