[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] Type expression matching annotation values: String matching, numeric ranges, etc?
|
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.