users@jaxb.java.net

Re: CodeModel and nested annotations

From: Kenny MacLeod <kennym_at_kizoom.com>
Date: Wed, 11 Jun 2008 10:24:38 +0100

Ah, that's the one. I never could get my head around that API style :)

cheers fella.


Aleksei Valikov wrote:
> Hi.
>
>> Morning folks,
>>
>> I'm trying to figure out how to set up nested annotations using the XJC
>> CodeModel.
>>
>> For example, I want to generate this sort of thing:
>>
>> @X({
>> @Y(a="b"),
>> @Y(c="d")
>> })
>> public class C {}
>>
>> Once I've added the @X (using JAnnotatable.annotate), the returned
>> JAnnotationUse object doesn't seem to offer a way of adding the @Y array, it
>> only offers methods to add scalar parameters.
>>
>> What am I missing?
>
> Try something like:
>
> final JAnnotationArrayMember ys = myAnnotationUse.paramArray("value");
> ys.annotate(Y.class).param("a", "b");
> ys.annotate(Y.class).param("c", "d");
>
> Also see annox.dev.java.net and the annotate plugin in jaxb2-commons.
>
> Bye.
> /lexi
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>