Package randoop.reflection
Class TypeExtractor
- java.lang.Object
-
- randoop.reflection.DefaultClassVisitor
-
- randoop.reflection.TypeExtractor
-
- All Implemented Interfaces:
ClassVisitor
class TypeExtractor extends DefaultClassVisitor
TypeExtractor
is aClassVisitor
that extracts both the class type, and concrete types that are used in a class as either a parameter, a return type, or a field type.
-
-
Field Summary
Fields Modifier and Type Field Description private Set<Type>
inputTypes
The set of concrete types.private AccessibilityPredicate
predicate
The accessibility predicate for checking whether a type is accessible in generated tests.
-
Constructor Summary
Constructors Constructor Description TypeExtractor(Set<Type> inputTypes, AccessibilityPredicate predicate)
Creates a visitor that adds discovered concrete types to the given set if they satisfy the accessibility predicate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addIfConcrete(Type type)
Determines whether the given general type is not generic, and, if so, adds the concrete type to the input types of this object.void
visit(Class<?> c, ReflectionManager reflectionManager)
Perform action on member class.void
visit(Constructor<?> c)
Perform action on a constructor.void
visit(Field f)
Perform an action on a field.void
visit(Method m)
Perform an action on a method.void
visitBefore(Class<?> c)
Perform an action on a class.-
Methods inherited from class randoop.reflection.DefaultClassVisitor
toString, visit, visitAfter
-
-
-
-
Field Detail
-
predicate
private final AccessibilityPredicate predicate
The accessibility predicate for checking whether a type is accessible in generated tests.
-
-
Constructor Detail
-
TypeExtractor
TypeExtractor(Set<Type> inputTypes, AccessibilityPredicate predicate)
Creates a visitor that adds discovered concrete types to the given set if they satisfy the accessibility predicate.- Parameters:
inputTypes
- the set of concrete typespredicate
- the accessibility predicate
-
-
Method Detail
-
visit
public void visit(Class<?> c, ReflectionManager reflectionManager)
Description copied from interface:ClassVisitor
Perform action on member class.The
ReflectionManager
is needed to allow visitors to initiate recursive visits if needed.- Specified by:
visit
in interfaceClassVisitor
- Overrides:
visit
in classDefaultClassVisitor
- Parameters:
c
- the member classreflectionManager
- theReflectionManager
that called this visitor
-
visit
public void visit(Constructor<?> c)
Perform action on a constructor.Adds all concrete parameter types from the constructor to the input types set of this object.
- Specified by:
visit
in interfaceClassVisitor
- Overrides:
visit
in classDefaultClassVisitor
- Parameters:
c
- the constructor
-
visit
public void visit(Method m)
Perform an action on a method.Adds any concrete type among parameter and return types to the input types set of this object. Avoids bridge methods, because may have rawtypes not useful in building tests.
- Specified by:
visit
in interfaceClassVisitor
- Overrides:
visit
in classDefaultClassVisitor
- Parameters:
m
- the method
-
visit
public void visit(Field f)
Perform an action on a field.Adds a concrete field type to the input types set of this object.
- Specified by:
visit
in interfaceClassVisitor
- Overrides:
visit
in classDefaultClassVisitor
- Parameters:
f
- the field
-
addIfConcrete
private void addIfConcrete(Type type)
Determines whether the given general type is not generic, and, if so, adds the concrete type to the input types of this object.- Parameters:
type
- the general type
-
visitBefore
public void visitBefore(Class<?> c)
Perform an action on a class. Occurs before other visit methods are called.Adds the class if it is concrete.
- Specified by:
visitBefore
in interfaceClassVisitor
- Overrides:
visitBefore
in classDefaultClassVisitor
- Parameters:
c
- the class to visit
-
-