Klasse JqwikReflectionSupport

java.lang.Object
net.jqwik.engine.support.JqwikReflectionSupport

public class JqwikReflectionSupport extends Object
  • Konstruktordetails

    • JqwikReflectionSupport

      public JqwikReflectionSupport()
  • Methodendetails

    • newInstanceWithDefaultConstructor

      public static <T> T newInstanceWithDefaultConstructor(Class<T> clazz)
      Create instance of a class that can potentially be a non static inner class
      Typparameter:
      T - The type of the instance to create
      Parameter:
      clazz - The class to instantiate
      Gibt zurück:
      the newly created instance
    • newInstancesWithDefaultConstructor

      public static List<Object> newInstancesWithDefaultConstructor(Class<?> clazz)
      Create instance of a class that can potentially be a non static inner class
      Parameter:
      clazz - The class to instantiate
      Gibt zurück:
      all newly created instances with from most outer to most inner
    • newInstanceInTestContext

      public static <T> T newInstanceInTestContext(Class<T> clazz, Object context)
      Create instance of a class that can potentially be a non static inner class and its outer instance might be context
      Typparameter:
      T - The type of the instance to create
      Parameter:
      clazz - The class to instantiate
      context - The potential context instance
      Gibt zurück:
      the newly created instance
    • newInstance

      public static <T> T newInstance(Constructor<T> constructor, Object... args)
    • findMethodsPotentiallyOuter

      public static List<Method> findMethodsPotentiallyOuter(Class<?> clazz, Predicate<Method> predicate, org.junit.platform.commons.support.HierarchyTraversalMode traversalMode)
      Find all methods as in ReflectionSupport.findMethods(..) but also use outer classes to look for methods.

      Duplicate methods (through) inheritance are de-duplicated. The first occurrence of a method is kept.

      Parameter:
      clazz - The class in which you start the search
      predicate - The condition to check for all candidate methods
      traversalMode - Traverse hierarchy up or down. Determines the order in resulting list.
      Gibt zurück:
      List of found methods
    • findFieldsPotentiallyOuter

      public static List<Field> findFieldsPotentiallyOuter(Class<?> clazz, Predicate<Field> predicate, org.junit.platform.commons.support.HierarchyTraversalMode traversalMode)
      Find all field but also use outer classes to look for methods.
      Parameter:
      clazz - The class in which you start the search
      predicate - The condition to check for all candidate methods
      traversalMode - Traverse hierarchy up or down. Determines the order in resulting list.
      Gibt zurück:
      List of found fields
    • readFieldOnContainer

      public static Object readFieldOnContainer(Field field, List<Object> targetInstances)
      Read a field's value as in ReflectionSupport.getField(..) but potentially use outer instances if the field belongs to an inner class.
      Parameter:
      field - The field to read
      targetInstances - The container instances to read the field from, from outermost to innermost
      Gibt zurück:
      The value of the field
    • setFieldOnContainer

      public static void setFieldOnContainer(Field field, Object value, List<Object> targetInstances)
      Set a field's value as in ReflectionSupport.setField(..) but potentially use outer instances if the field belongs to an inner class.
      Parameter:
      field - The field to set
      value - The value to set in the field
      targetInstances - The container instances to set the field on, from outermost to innermost
    • invokeMethodOnContainer

      public static Object invokeMethodOnContainer(Method method, List<Object> instances, Object... args)
      Invoke the supplied method as in ReflectionSupport.invokeMethod(..) but potentially use outer instances if the method belongs to the outer instances of an object.
      Parameter:
      method - The method to invoke
      instances - The container instances to invoke the method on, from outermost to innermost
      args - The arguments of the method invocation
      Gibt zurück:
      Result of method invocation if there is one, otherwise null
    • getAllClasspathRootDirectories

      public static Set<Path> getAllClasspathRootDirectories()
    • getMethodParameters

      public static List<MethodParameter> getMethodParameters(Executable method, Class<?> containerClass)
    • getMethodParameter

      public static MethodParameter getMethodParameter(Parameter parameter, int index, Class<?> containerClass)
    • findGeneratorMethod

      public static Optional<Method> findGeneratorMethod(String generatorToFind, Class<?> containerClass, Class<? extends Annotation> requiredGeneratorAnnotation, Function<Method,String> generatorNameSupplier, net.jqwik.api.providers.TypeUsage expectedReturnType)
    • findConstructor

      public static <T> Constructor<T> findConstructor(Class<T> type, Class<?>... parameterTypes)
    • isInnerClass

      public static boolean isInnerClass(Class<?> clazz)
    • isFunctionalType

      public static boolean isFunctionalType(Class<?> candidateType)
    • getFunctionMethod

      public static Optional<Method> getFunctionMethod(Class<?> candidateType)
    • isEqualsMethod

      public static boolean isEqualsMethod(Method method)
    • isToStringMethod

      public static boolean isToStringMethod(Method method)
    • isHashCodeMethod

      public static boolean isHashCodeMethod(Method method)
    • hasDefaultConstructor

      public static boolean hasDefaultConstructor(Class<?> aClass)
    • hasConstructor

      public static boolean hasConstructor(Class<?> aClass, Class<?>... parameterTypes)
    • isJava9orAbove

      public static boolean isJava9orAbove()
    • isStatic

      public static boolean isStatic(Class<?> clazz)
    • isPrivate

      public static boolean isPrivate(Class<?> clazz)
    • isNotStatic

      public static boolean isNotStatic(Class<?> clazz)
    • isStatic

      public static boolean isStatic(Member member)
    • isNotStatic

      public static boolean isNotStatic(Member member)
    • returnsVoid

      public static boolean returnsVoid(Method method)
    • implementsMethod

      public static boolean implementsMethod(Class<?> aClass, String methodName, Class<?>[] parameterTypes, Class<?> ignoreImplementationClass)
    • extractRawType

      public static Class<?> extractRawType(Type parameterizedType)