List of usage examples for com.google.gwt.core.ext.typeinfo AnnotationsHelper getAnnotations
public static Annotation[] getAnnotations(JParameter type)
From source file:com.gwtent.gen.GenUtils.java
License:Apache License
/** * Get annotation from a classType.//from w ww.j a v a 2 s.co m * This function will search all super class to try to find out the annotation. * If not found in super class, this function will try all implement interfaces. * * @param <T> * @param classType The class type * @param annotationClass The annotation class * @return if found, return the annotation, otherwise return null */ public static <T extends Annotation> T getClassTypeAnnotationWithMataAnnotation(JClassType classType, Class<T> annotationClass) { JClassType parent = classType; while (parent != null) { Annotation[] annotations = AnnotationsHelper.getAnnotations(parent); for (Annotation annotation : annotations) { T result = getAnnotationFromAnnotation(annotation, annotationClass); if (result != null) return result; } parent = parent.getSuperclass(); } //if not found in super class, found it in implement interfaces parent = classType; while (parent != null) { for (JClassType inter : parent.getImplementedInterfaces()) { T result = getClassTypeAnnotationWithMataAnnotation(inter, annotationClass); if (result != null) return result; } parent = parent.getSuperclass(); } return null; }
From source file:com.gwtent.gen.reflection.ReflectAllInOneCreator.java
License:Apache License
private void processAnnotationClasses(HasAnnotations annotations, Reflectable reflectable) { if (!reflectable.classAnnotations()) return;/*from w w w . jav a2 s . com*/ Annotation[] annos = AnnotationsHelper.getAnnotations(annotations); if (annos == null) return; for (Annotation annotation : annos) { processAnnotation(annotation); } }