All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.testng.internal.annotations.IAnnotationFinder Maven / Gradle / Ivy

There is a newer version: 7.10.2
Show newest version
package org.testng.internal.annotations;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.List;
import org.testng.ITestNGMethod;
import org.testng.annotations.IAnnotation;
import org.testng.internal.ConstructorOrMethod;

/**
 * This interface defines how annotations are found on classes, methods and constructors. It will be
 * implemented by both JDK 1.4 and JDK 5 annotation finders.
 */
public interface IAnnotationFinder {

  /**
   * @param cls - The corresponding class.
   * @param annotationClass - The class on which annotation is to be looked for.
   * @param  The expected {@link IAnnotation} type
   * @return The annotation on the class or null if none found.
   */
   A findAnnotation(Class cls, Class annotationClass);

  /**
   * @param m - The corresponding {@link Method}
   * @param annotationClass - The class on which annotation is to be looked for.
   * @param  The expected {@link IAnnotation} type
   * @return The annotation on the method. If not found, return the annotation on the declaring
   *     class. If not found, return null.
   */
   A findAnnotation(Method m, Class annotationClass);

   A findAnnotation(ITestNGMethod m, Class annotationClass);

   A findAnnotation(ConstructorOrMethod com, Class annotationClass);

   A findAnnotation(
      Class clazz, Method m, java.lang.Class annotationClass);

  /**
   * @param cons - The corresponding {@link Constructor}
   * @param annotationClass - The class on which annotation is to be looked for.
   * @param  The expected {@link IAnnotation} type
   * @return The annotation on the method. If not found, return the annotation on the declaring
   *     class. If not found, return null.
   */
   A findAnnotation(Constructor cons, Class annotationClass);

  /**
   * @param cls - The corresponding class.
   * @param annotationClass - The class on which annotation is to be looked for.
   * @param  - The expected {@link IAnnotation} type
   * @return The annotations on the inherited interfaces. If not found, return the annotations on
   *     the declaring interface. If not found, return an empty list.
   */
   List findInheritedAnnotations(Class cls, Class annotationClass);

  /**
   * @param method The Method
   * @param i The parameter index
   * @return true if the ith parameter of the given method has the annotation @TestInstance.
   */
  boolean hasTestInstance(Method method, int i);

  /**
   * @param method The Method
   * @return the @Optional values of this method's parameters (null if the parameter
   *     isn't optional)
   */
  String[] findOptionalValues(Method method);

  /**
   * @param ctor The Constructor
   * @return the @Optional values of this method's parameters (null if the parameter
   *     isn't optional)
   */
  String[] findOptionalValues(Constructor ctor);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy