gwt /
gwt /
c620162af803368a3a75fdfb7c67c0eda7a64531 This patch adds annotation support to the TypeOracle used by generators. It is a departure from what we have done previously because it models annotations as actual instances that you invoke methods on instead of metadata which is merely inspected. In this regard it is more like APT and java.lang.annotation.Annotation than our current MetaData API. Because of this, generators will now be able to use solutions of the form:
// Special annotation
public @interface MyAnnotation {
String value();
}
// Generator implementation
TypeOracle typeOracle = getTypeOracle();
JClassType annotatedClass = typeOracle.getType("com...");
MyAnnotation myAnnotation = annotatedClass.getAnnotation(MyAnnotation.class);
if (myAnnotation.value().equals("SpecialValue")) {
...
}
This seems like it would be more useful to a developer than a set of name value pairs.
Possible future enhancements:
Ability to ask the TypeOracle for all elements that have a particular annotation.
Homoginize with the existing metadata API, i.e. gwt.typeArgs, et al.
Patch by: mmendez, tobyr, scottb
Review by: scottb, mmendez, tobyr (some pair prog + desk checking)
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1423 8db76d5a-ed1c-0410-87a9-c151d255dfc7
23 files changed