Package net.jqwik.engine.support
Class JqwikReflectionSupport
java.lang.Object
net.jqwik.engine.support.JqwikReflectionSupport
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Class<?>extractRawType(Type parameterizedType) static <T> Constructor<T>findConstructor(Class<T> type, Class<?>... parameterTypes) 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.findGeneratorMethod(String generatorToFind, Class<?> containerClass, Class<? extends Annotation> requiredGeneratorAnnotation, Function<Method, String> generatorNameSupplier, net.jqwik.api.providers.TypeUsage expectedReturnType) 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.getFunctionMethod(Class<?> candidateType) getInstancesFromInside(Object inner) static MethodParametergetMethodParameter(Parameter parameter, int index, Class<?> containerClass) static List<MethodParameter>getMethodParameters(Executable method, Class<?> containerClass) static booleanhasConstructor(Class<?> aClass, Class<?>... parameterTypes) static booleanhasDefaultConstructor(Class<?> aClass) static booleanimplementsMethod(Class<?> aClass, String methodName, Class<?>[] parameterTypes, Class<?> ignoreImplementationClass) static ObjectinvokeMethodPotentiallyOuter(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.static booleanisEqualsMethod(Method method) static booleanisFunctionalType(Class<?> candidateType) static booleanisHashCodeMethod(Method method) static booleanisInnerClass(Class<?> clazz) static booleanstatic booleanisNotStatic(Class<?> clazz) static booleanisNotStatic(Member member) static booleanstatic booleanstatic booleanstatic booleanisToStringMethod(Method method) static <T> TnewInstance(Constructor<T> constructor, Object... args) static <T> TnewInstanceInTestContext(Class<T> clazz, Object context) Create instance of a class that can potentially be a non static inner class and its outer instance might becontextstatic <T> TnewInstanceWithDefaultConstructor(Class<T> clazz) Create instance of a class that can potentially be a non static inner classstatic ObjectreadFieldPotentiallyOuter(Field field, Object target) static booleanreturnsVoid(Method method) static voidsetFieldPotentiallyOuter(Field field, Object value, Object target) streamInstancesFromInside(Object inner)
-
Constructor Details
-
JqwikReflectionSupport
public JqwikReflectionSupport()
-
-
Method Details
-
streamInstancesFromInside
-
getInstancesFromInside
-
newInstanceWithDefaultConstructor
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
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
-
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 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
-
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 searchpredicate- The condition to check for all candidate methodstraversalMode- Traverse hierarchy up or down. Determines the order in resulting list.- Returns:
- List of found fields
-
readFieldPotentiallyOuter
-
setFieldPotentiallyOuter
-
invokeMethodPotentiallyOuter
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
-
getMethodParameters
-
getMethodParameter
public static MethodParameter getMethodParameter(Parameter parameter, int index, Class<?> containerClass) -
findGeneratorMethod
-
findConstructor
-
isInnerClass
-
isFunctionalType
-
getFunctionMethod
-
isEqualsMethod
-
isToStringMethod
-
isHashCodeMethod
-
hasDefaultConstructor
-
hasConstructor
-
isJava9orAbove
public static boolean isJava9orAbove() -
isStatic
-
isPrivate
-
isNotStatic
-
isStatic
-
isNotStatic
-
returnsVoid
-
implementsMethod
-
extractRawType
-