Class JqwikReflectionSupport

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

public class JqwikReflectionSupport extends Object
  • Constructor Details

    • JqwikReflectionSupport

      public JqwikReflectionSupport()
  • Method Details

    • streamInstancesFromInside

      public static Stream<Object> streamInstancesFromInside(Object inner)
    • getInstancesFromInside

      public static List<Object> getInstancesFromInside(Object inner)
    • newInstanceWithDefaultConstructor

      public static <T> T newInstanceWithDefaultConstructor(Class<T> clazz)
      Create instance of a class that can potentially be a non static inner class
      Type Parameters:
      T - The type of the instance to create
      Parameters:
      clazz - The class to instantiate
      Returns:
      the newly created instance
    • 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
      Type Parameters:
      T - The type of the instance to create
      Parameters:
      clazz - The class to instantiate
      context - The potential context instance
      Returns:
      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.
      Parameters:
      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.
      Returns:
      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.
      Parameters:
      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.
      Returns:
      List of found fields
    • readFieldPotentiallyOuter

      public static Object readFieldPotentiallyOuter(Field field, Object target)
    • setFieldPotentiallyOuter

      public static void setFieldPotentiallyOuter(Field field, Object value, Object target)
    • invokeMethodPotentiallyOuter

      public static Object invokeMethodPotentiallyOuter(Method method, Object target, Object... args)
      Invoke the supplied method as in ReflectionSupport.invokeMethod(..) but potentially use the outer instance if the method belongs to the outer instance of an object.
      Parameters:
      method - The method to invoke
      target - The object to invoke the method on
      args - The arguments of the method invocation
      Returns:
      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)