I think that would be great, and would provide a lot of flexibility - but
it is quite a lot of work... Most cycles are going to get consumed on
supporting Java 8 for the next little while. I'm sure when you start
thinking about type annotations (jsr308) you are going to come up with a
million new AspectJ use cases...
For strings I might be happier with using a regex of some kind rather than
getting into what methods are or are not allowed.
@Foo(value =~ "/^goo.*/")
For numbers the usual set of operators seem ok. I'm still waiting for
someone to tell me the best operator for that 'member of array' construct
we were talking about previously:
@Foo({1,2,3})
declare @type: @Foo(value ???? 1): @ContainsOne;
cheers,
Andy
On 25 April 2013 20:08, Matthew Adams <[email protected]> wrote:
> So as I've been kicking around some of the type expression enhancements, in
> particular, https://bugs.eclipse.org/bugs/show_bug.cgi?id=405016, it
> occurred to me that, IMHO, there should be a limited type expression syntax
> for matching annotation values.
>
> For example, consider annotation values of type String. It would be nice
> to
> match case sensitively, insensitively, or even match a regex. The syntax
> for that could look something like the following type expression examples.
> Given
>
> public @interface Foo { String value(); }
>
> these would be allowed:
>
> (@Foo(value = "goo") *)
> (@Foo(value.equals("goo")) *) // same as above
> (@Foo(value.equalsIgnoreCase("goo")) *)
> (@Foo(value.startsWith("goo")) *)
> (@Foo(value.endsWith("goo")) *)
> (@Foo(value.matches("go{2}")) *)
> (@Foo(value.trim().length() > 0) *)
> ...
>
> Any appropriate method or expression that returns boolean seems
> supportable.
>
> As for numeric types (primitives & wrappers), given
>
> public @interface Bar { int value(); }
>
> these would be allowable:
>
> (@Bar(value > 10) *)
> (@Bar(value >= 0 && value < 10) *)
> (@Bar(value % 2 == 0) *)
> ...
>
> Since these type expressions are evaluatable statically (since all
> annotation values must be constants), this seems fully validatable at
> compile time.
>
> Thoughts?
>
> -matthew
>
>
>
> --
> View this message in context:
> http://aspectj.2085585.n4.nabble.com/Type-expression-matching-annotation-values-String-matching-numeric-ranges-etc-tp4650906.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users