Package net.jqwik.engine.support
Class JqwikReflectionSupport
- java.lang.Object
-
- net.jqwik.engine.support.JqwikReflectionSupport
-
public class JqwikReflectionSupport extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description JqwikReflectionSupport()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> java.lang.reflect.Constructor<T>findConstructor(java.lang.Class<T> type, java.lang.Class<?>... parameterTypes)static java.util.Optional<java.lang.reflect.Method>findGeneratorMethod(java.lang.String generatorToFind, java.lang.Class<?> containerClass, java.lang.Class<? extends java.lang.annotation.Annotation> requiredGeneratorAnnotation, java.util.function.Function<java.lang.reflect.Method,java.lang.String> generatorNameSupplier, net.jqwik.api.providers.TypeUsage targetType)static java.util.List<java.lang.reflect.Method>findMethodsPotentiallyOuter(java.lang.Class<?> clazz, java.util.function.Predicate<java.lang.reflect.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.static java.util.Set<java.nio.file.Path>getAllClasspathRootDirectories()static java.util.Optional<java.lang.reflect.Method>getFunctionMethod(java.lang.Class<?> candidateType)static MethodParametergetMethodParameter(java.lang.reflect.Parameter parameter, int index, java.lang.Class<?> containerClass)static java.util.List<MethodParameter>getMethodParameters(java.lang.reflect.Method method, java.lang.Class<?> containerClass)static booleanhasDefaultConstructor(java.lang.Class<?> aClass)static java.lang.ObjectinvokeMethodPotentiallyOuter(java.lang.reflect.Method method, java.lang.Object target, java.lang.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.static booleanisEqualsMethod(java.lang.reflect.Method method)static booleanisFunctionalType(java.lang.Class<?> candidateType)static java.util.function.Predicate<java.lang.reflect.Method>isGeneratorMethod(net.jqwik.api.providers.TypeUsage targetType, java.lang.Class<? extends java.lang.annotation.Annotation> requiredAnnotation)static booleanisHashCodeMethod(java.lang.reflect.Method method)static booleanisInnerClass(java.lang.Class<?> clazz)static booleanisJava9orAbove()static booleanisNotStatic(java.lang.Class<?> clazz)static booleanisNotStatic(java.lang.reflect.Member member)static booleanisStatic(java.lang.Class<?> clazz)static booleanisStatic(java.lang.reflect.Member member)static booleanisToStringMethod(java.lang.reflect.Method method)static <T> TnewInstance(java.lang.reflect.Constructor<T> constructor, java.lang.Object... args)static <T> TnewInstanceInTestContext(java.lang.Class<T> clazz, java.lang.Object context)Create instance of a class that can potentially be a non static inner class and its outer instance might becontextstatic <T> TnewInstanceWithDefaultConstructor(java.lang.Class<T> clazz)Create instance of a class that can potentially be a non static inner classstatic booleanreturnsVoid(java.lang.reflect.Method method)static java.util.stream.Stream<java.lang.Object>streamInstancesFromInside(java.lang.Object inner)
-
-
-
Method Detail
-
streamInstancesFromInside
public static java.util.stream.Stream<java.lang.Object> streamInstancesFromInside(java.lang.Object inner)
-
newInstanceWithDefaultConstructor
public static <T> T newInstanceWithDefaultConstructor(java.lang.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(java.lang.Class<T> clazz, java.lang.Object context)Create instance of a class that can potentially be a non static inner class and its outer instance might becontext- Type Parameters:
T- The type of the instance to create- Parameters:
clazz- The class to instantiatecontext- The potential context instance- Returns:
- the newly created instance
-
newInstance
public static <T> T newInstance(java.lang.reflect.Constructor<T> constructor, java.lang.Object... args)
-
findMethodsPotentiallyOuter
public static java.util.List<java.lang.reflect.Method> findMethodsPotentiallyOuter(java.lang.Class<?> clazz, java.util.function.Predicate<java.lang.reflect.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 searchpredicate- The condition to check for all candidate methodstraversalMode- Traverse hierarchy up or down. Determines the order in resulting list.- Returns:
- List of found methods
-
invokeMethodPotentiallyOuter
public static java.lang.Object invokeMethodPotentiallyOuter(java.lang.reflect.Method method, java.lang.Object target, java.lang.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 invoketarget- The object to invoke the method onargs- The arguments of the method invocation- Returns:
- Result of method invocation if there is one, otherwise null
-
getAllClasspathRootDirectories
public static java.util.Set<java.nio.file.Path> getAllClasspathRootDirectories()
-
getMethodParameters
public static java.util.List<MethodParameter> getMethodParameters(java.lang.reflect.Method method, java.lang.Class<?> containerClass)
-
getMethodParameter
public static MethodParameter getMethodParameter(java.lang.reflect.Parameter parameter, int index, java.lang.Class<?> containerClass)
-
findGeneratorMethod
public static java.util.Optional<java.lang.reflect.Method> findGeneratorMethod(java.lang.String generatorToFind, java.lang.Class<?> containerClass, java.lang.Class<? extends java.lang.annotation.Annotation> requiredGeneratorAnnotation, java.util.function.Function<java.lang.reflect.Method,java.lang.String> generatorNameSupplier, net.jqwik.api.providers.TypeUsage targetType)
-
findConstructor
public static <T> java.lang.reflect.Constructor<T> findConstructor(java.lang.Class<T> type, java.lang.Class<?>... parameterTypes)
-
isGeneratorMethod
public static java.util.function.Predicate<java.lang.reflect.Method> isGeneratorMethod(net.jqwik.api.providers.TypeUsage targetType, java.lang.Class<? extends java.lang.annotation.Annotation> requiredAnnotation)
-
isInnerClass
public static boolean isInnerClass(java.lang.Class<?> clazz)
-
isFunctionalType
public static boolean isFunctionalType(java.lang.Class<?> candidateType)
-
getFunctionMethod
public static java.util.Optional<java.lang.reflect.Method> getFunctionMethod(java.lang.Class<?> candidateType)
-
isEqualsMethod
public static boolean isEqualsMethod(java.lang.reflect.Method method)
-
isToStringMethod
public static boolean isToStringMethod(java.lang.reflect.Method method)
-
isHashCodeMethod
public static boolean isHashCodeMethod(java.lang.reflect.Method method)
-
hasDefaultConstructor
public static boolean hasDefaultConstructor(java.lang.Class<?> aClass)
-
isJava9orAbove
public static boolean isJava9orAbove()
-
isStatic
public static boolean isStatic(java.lang.Class<?> clazz)
-
isNotStatic
public static boolean isNotStatic(java.lang.Class<?> clazz)
-
isStatic
public static boolean isStatic(java.lang.reflect.Member member)
-
isNotStatic
public static boolean isNotStatic(java.lang.reflect.Member member)
-
returnsVoid
public static boolean returnsVoid(java.lang.reflect.Method method)
-
-