Hi,

I was wondering if there was an easy way (I did look but found
nothing) to get the Annotation class corresponding to a particular
Type.

As I did not find any I wrote this hacky method... but I don't like
it, it looks too hacky to work for long !

public static Class<? extends Annotation> typeToAnnotation(Type t) {
  // We need to access the class of the annotation corresponding to the
  // type to use as item
  String typename  = t.getName();
  String annotname = typename.replace("_Type", "");
  Class<? extends Annotation> itemclass = (Class<? extends
Annotation>) Class.forName(annotname);
  return itemclass;
}

What do you think ? Do you have any pointer ? I deeped into the
LowLevelTypeSystem as well as the FSGenerator but found nothing.

--
Fabien Poulard

Reply via email to