Andy,

Thanks for the quick answer. I've submitted an enhancement request. Let me
know
if it needs more detail.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=345515

Thanks.
--
Adam

On Wed, May 11, 2011 at 4:22 PM, Andy Clement <andrew.clem...@gmail.com>wrote:

> Hi,
>
> I'm afraid you can't do that with AspectJ right now, you can't pass a
> piece of the matched information to the new annotation.  I can perhaps
> imagine some hypothetical syntax:
>
> declare @field:
> @SortedOneToMany(sort=SortType.COMPARATOR,comparator={1}) * * :
> @Sort(type=SortType.COMPARATOR,comparator={1});
>
> which would seem to achieve what you want.
>
> Maybe raise an enhancement request for it:
> https://bugs.eclipse.org/bugs/enter_bug.cgi?product=AspectJ
>
> sorry I don't have better news.
>
> cheers
> Andy
>
> On 11 May 2011 13:55, Adam Howard <howard.a...@gmail.com> wrote:
> > I've asked this question on StackOverflow and have not gotten an answer
> > after 115 views so I thought
> > I would ask here. You can post your answer on SO too if you'd like the
> rep.
> >
> http://stackoverflow.com/questions/5901690/turning-one-annotation-into-many-annotations-with-aspectj
> > I have discovered a pattern in my JPA mappings that I would like to
> codify.
> > A simple example follows:
> >     @OneToMany(fetch=FetchType.EAGER)
> >     @Sort(type=SortType.NATURAL)
> >     private SortedSet<Item> items;
> > I would like to create a single annotation called SortedOneToMany that I
> can
> > apply to the above set:
> >     public @interface SortedOneToMany {
> >         FetchType fetch() default EAGER;
> >         SortType sort() default NATURAL;
> >         Class comparator() default void.class;
> >     }
> > I have written the following aspect to "attach" the JPA annotations
> whenever
> > it sees my annotation:
> >     public aspect SortedOneToManyAspect {
> >         declare @field: @SortedOneToMany * * :
> > @OneToMany(fetch=FetchType.EAGER);
> >         declare @field: @SortedOneToMany * * :
> @Sort(type=SortType.NATURAL);
> >     }
> > But I don't know how can I access the values of the SortedOneToMany
> > annotation parameters and use them when defining the OneToMany and Sort
> > annotations. There may be cases where I want to change one of the default
> > values like so:
> >
> >
> @SortedOneToMany(sort=SortType.COMPARATOR,comparator=ItemComparator.class)
> >     private SortedSet<Item> items;
> > So how can I pass the annotation values from SortedOneToMany to the Sort
> > annotation?
> > Thanks.
> > --
> > Adam
> >
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@eclipse.org
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> >
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to