1 package org.testng.internal.annotations; 2 3 import java.lang.reflect.Constructor; 4 import java.lang.reflect.Method; 5 6 import org.testng.ITestNGMethod; 7 import org.testng.annotations.IAnnotation; 8 9 10 /** 11 * This interface defines how annotations are found on classes, methods 12 * and constructors. It will be implemented by both JDK 1.4 and JDK 5 13 * annotation finders. 14 * 15 * @author <a href="mailto:cedric@beust.com">Cedric Beust</a> 16 */ 17 public interface IAnnotationFinder { 18 19 /** 20 * @param cls 21 * @param annotationClass 22 * @return The annotation on the class or null if none found. 23 */ findAnnotation(Class<?> cls, Class<A> annotationClass)24 public <A extends IAnnotation> A findAnnotation(Class<?> cls, Class<A> annotationClass); 25 26 /** 27 * @param m 28 * @param annotationClass 29 * @return The annotation on the method. 30 * If not found, return the annotation on the declaring class. 31 * If not found, return null. 32 */ findAnnotation(Method m, Class<A> annotationClass)33 public <A extends IAnnotation> A findAnnotation(Method m, Class<A> annotationClass); findAnnotation(ITestNGMethod m, Class<A> annotationClass)34 <A extends IAnnotation> A findAnnotation(ITestNGMethod m, Class<A> annotationClass); 35 36 /** 37 * @param cons 38 * @param annotationClass 39 * @return The annotation on the method. 40 * If not found, return the annotation on the declaring class. 41 * If not found, return null. 42 */ findAnnotation(Constructor<?> cons, Class<A> annotationClass)43 public <A extends IAnnotation> A findAnnotation(Constructor<?> cons, Class<A> annotationClass); 44 45 /** 46 * @return true if the ith parameter of the given method has the annotation @TestInstance. 47 */ hasTestInstance(Method method, int i)48 public boolean hasTestInstance(Method method, int i); 49 50 /** 51 * @return the @Optional values of this method's parameters (<code>null</code> 52 * if the parameter isn't optional) 53 */ findOptionalValues(Method method)54 public String[] findOptionalValues(Method method); 55 56 /** 57 * @return the @Optional values of this method's parameters (<code>null</code> 58 * if the parameter isn't optional) 59 */ findOptionalValues(Constructor ctor)60 public String[] findOptionalValues(Constructor ctor); 61 } 62