public class OperationExtractor extends DefaultClassVisitor
ClassVisitor that creates a collection of TypedOperation
objects for a particular ClassOrInterfaceType through its visit methods as called by
ReflectionManager.apply(Class).
The returned operations (available by calling the getOperations() method) contain any
relevant specification from operationSpecifications.
ReflectionManager,
ClassVisitor| Modifier and Type | Field and Description |
|---|---|
private AccessibilityPredicate |
accessibilityPredicate
The predicate to test accessibility.
|
private ClassOrInterfaceType |
classType
The type of the declaring class for the collected operations.
|
private static boolean |
debug
Whether to produce debugging output to the Randoop log.
|
private OmitMethodsPredicate |
omitPredicate
The predicate to test whether to omit an operation.
|
private java.util.Collection<TypedOperation> |
operations
The operations collected by the extractor.
|
private SpecificationCollection |
operationSpecifications
The specifications (pre/post/throws-conditions).
|
private ReflectionPredicate |
reflectionPredicate
The reflection policy for collecting operations.
|
| Constructor and Description |
|---|
OperationExtractor(ClassOrInterfaceType classType,
ReflectionPredicate reflectionPredicate,
AccessibilityPredicate accessibilityPredicate)
Creates a visitor object that collects the
TypedOperation objects corresponding to
members of the class satisfying the given accessibility and reflection predicates. |
OperationExtractor(ClassOrInterfaceType classType,
ReflectionPredicate reflectionPredicate,
OmitMethodsPredicate omitPredicate,
AccessibilityPredicate accessibilityPredicate)
Creates a visitor object that collects the
TypedOperation objects corresponding to
members of the class satisfying the given accessibility and reflection predicates. |
OperationExtractor(ClassOrInterfaceType classType,
ReflectionPredicate reflectionPredicate,
OmitMethodsPredicate omitPredicate,
AccessibilityPredicate accessibilityPredicate,
SpecificationCollection operationSpecifications)
Creates a visitor object that collects the
TypedOperation objects corresponding to
members of the class satisfying the given accessibility and reflection predicates and that
don't violate the omit method predicate. |
| Modifier and Type | Method and Description |
|---|---|
private void |
checkSubTypes(TypedClassOperation operation)
Ensures that field
classType of this object is a subtype of operation.getDeclaringType(); throws an exception if not. |
static java.util.List<ClassOrInterfaceType> |
classListToTypeList(java.util.List<java.lang.Class<?>> classes)
Converts a list of classes to a list of ClassOrInterfaceType.
|
java.util.Collection<TypedOperation> |
getOperations()
Returns the
TypedOperation objects collected for classType. |
private TypedClassOperation |
instantiateTypes(TypedClassOperation operation)
Updates the operation types in the case that
operation.getDeclaringType() is generic,
but classType is not. |
static java.util.List<TypedOperation> |
operations(java.lang.Class<?> clazz,
ReflectionPredicate reflectionPredicate,
AccessibilityPredicate accessibilityPredicate)
Returns the operations in the class that satisfy the given predicates.
|
static java.util.List<TypedOperation> |
operations(java.lang.Class<?> clazz,
ReflectionPredicate reflectionPredicate,
OmitMethodsPredicate omitPredicate,
AccessibilityPredicate accessibilityPredicate)
Returns the operations in the class that satisfy the given predicates.
|
static java.util.List<TypedOperation> |
operations(java.lang.Class<?> clazz,
ReflectionPredicate reflectionPredicate,
OmitMethodsPredicate omitMethodsPredicate,
AccessibilityPredicate accessibilityPredicate,
SpecificationCollection operationSpecifications)
Returns the operations in the class that satisfy the given predicates.
|
static java.util.List<TypedOperation> |
operations(ClassOrInterfaceType classType,
ReflectionPredicate reflectionPredicate,
AccessibilityPredicate accessibilityPredicate)
Returns the operations in the class that satisfy the given predicates.
|
static java.util.List<TypedOperation> |
operations(ClassOrInterfaceType classType,
ReflectionPredicate reflectionPredicate,
OmitMethodsPredicate omitPredicate,
AccessibilityPredicate accessibilityPredicate)
Returns the operations in the class that satisfy the given predicates.
|
static java.util.List<TypedOperation> |
operations(ClassOrInterfaceType classType,
ReflectionPredicate reflectionPredicate,
OmitMethodsPredicate omitMethodsPredicate,
AccessibilityPredicate accessibilityPredicate,
SpecificationCollection operationSpecifications)
Returns the operations in the class that satisfy the given predicates.
|
static java.util.List<TypedOperation> |
operations(java.util.Collection<ClassOrInterfaceType> classTypes,
ReflectionPredicate reflectionPredicate,
AccessibilityPredicate accessibilityPredicate)
Returns the operations in the class that satisfy the given predicates.
|
static java.util.List<TypedOperation> |
operations(java.util.Collection<ClassOrInterfaceType> classTypes,
ReflectionPredicate reflectionPredicate,
OmitMethodsPredicate omitPredicate,
AccessibilityPredicate accessibilityPredicate)
Returns the operations in the class that satisfy the given predicates.
|
static java.util.List<TypedOperation> |
operations(java.util.Collection<ClassOrInterfaceType> classTypes,
ReflectionPredicate reflectionPredicate,
OmitMethodsPredicate omitMethodsPredicate,
AccessibilityPredicate accessibilityPredicate,
SpecificationCollection operationSpecifications)
Returns the operations in the class that satisfy the given predicates.
|
void |
visit(java.lang.reflect.Constructor<?> constructor)
Creates a
ConstructorCall object for the Constructor. |
void |
visit(java.lang.Enum<?> e)
Creates a
EnumConstant object for the Enum. |
void |
visit(java.lang.reflect.Field field)
Adds the
Operation objects corresponding to getters and setters appropriate to the kind
of field. |
void |
visit(java.lang.reflect.Method method)
Creates a
MethodCall object for the Method. |
toString, visit, visitAfter, visitBeforeprivate static boolean debug
private ClassOrInterfaceType classType
private final java.util.Collection<TypedOperation> operations
private final ReflectionPredicate reflectionPredicate
private OmitMethodsPredicate omitPredicate
private final AccessibilityPredicate accessibilityPredicate
private final SpecificationCollection operationSpecifications
execSpec field of the returned TypedOperation.public OperationExtractor(ClassOrInterfaceType classType, ReflectionPredicate reflectionPredicate, OmitMethodsPredicate omitPredicate, AccessibilityPredicate accessibilityPredicate, SpecificationCollection operationSpecifications)
TypedOperation objects corresponding to
members of the class satisfying the given accessibility and reflection predicates and that
don't violate the omit method predicate.
Once created this visitor should only be applied to members of classType.getRuntimeType().
classType - the declaring class for collected operationsreflectionPredicate - the reflection predicateomitPredicate - the list of Pattern objects for omitting methods, may be nullaccessibilityPredicate - the predicate for test accessibilityoperationSpecifications - the specifications (pre/post/throws-conditions)public OperationExtractor(ClassOrInterfaceType classType, ReflectionPredicate reflectionPredicate, AccessibilityPredicate accessibilityPredicate)
TypedOperation objects corresponding to
members of the class satisfying the given accessibility and reflection predicates.classType - the declaring class for collected operationsreflectionPredicate - the reflection predicateaccessibilityPredicate - the predicate for test accessibilitypublic OperationExtractor(ClassOrInterfaceType classType, ReflectionPredicate reflectionPredicate, OmitMethodsPredicate omitPredicate, AccessibilityPredicate accessibilityPredicate)
TypedOperation objects corresponding to
members of the class satisfying the given accessibility and reflection predicates.classType - the declaring class for collected operationsreflectionPredicate - the reflection predicateomitPredicate - the list of Pattern objects for omitting methods, may be nullaccessibilityPredicate - the predicate for test accessibilitypublic static java.util.List<TypedOperation> operations(java.lang.Class<?> clazz, ReflectionPredicate reflectionPredicate, AccessibilityPredicate accessibilityPredicate)
clazz - the declaring class for collected operationsreflectionPredicate - the reflection predicateaccessibilityPredicate - the predicate for test accessibilitypublic static java.util.List<TypedOperation> operations(ClassOrInterfaceType classType, ReflectionPredicate reflectionPredicate, AccessibilityPredicate accessibilityPredicate)
classType - the declaring class for collected operationsreflectionPredicate - the reflection predicateaccessibilityPredicate - the predicate for test accessibilitypublic static java.util.List<TypedOperation> operations(java.util.Collection<ClassOrInterfaceType> classTypes, ReflectionPredicate reflectionPredicate, AccessibilityPredicate accessibilityPredicate)
classTypes - the declaring classes for collected operationsreflectionPredicate - the reflection predicateaccessibilityPredicate - the predicate for test accessibilitypublic static java.util.List<TypedOperation> operations(java.lang.Class<?> clazz, ReflectionPredicate reflectionPredicate, OmitMethodsPredicate omitPredicate, AccessibilityPredicate accessibilityPredicate)
clazz - the declaring class for collected operationsreflectionPredicate - the reflection predicateomitPredicate - the list of Pattern objects for omitting methods, may be nullaccessibilityPredicate - the predicate for test accessibilitypublic static java.util.List<TypedOperation> operations(ClassOrInterfaceType classType, ReflectionPredicate reflectionPredicate, OmitMethodsPredicate omitPredicate, AccessibilityPredicate accessibilityPredicate)
classType - the declaring class for collected operationsreflectionPredicate - the reflection predicateomitPredicate - the list of Pattern objects for omitting methods, may be nullaccessibilityPredicate - the predicate for test accessibilitypublic static java.util.List<TypedOperation> operations(java.util.Collection<ClassOrInterfaceType> classTypes, ReflectionPredicate reflectionPredicate, OmitMethodsPredicate omitPredicate, AccessibilityPredicate accessibilityPredicate)
classTypes - the declaring classes for collected operationsreflectionPredicate - the reflection predicateomitPredicate - the list of Pattern objects for omitting methods, may be nullaccessibilityPredicate - the predicate for test accessibilitypublic static java.util.List<TypedOperation> operations(java.lang.Class<?> clazz, ReflectionPredicate reflectionPredicate, OmitMethodsPredicate omitMethodsPredicate, AccessibilityPredicate accessibilityPredicate, SpecificationCollection operationSpecifications)
clazz - the declaring class for collected operationsreflectionPredicate - the reflection predicateomitMethodsPredicate - the list of Pattern objects for omitting methods, may be
nullaccessibilityPredicate - the predicate for test accessibilityoperationSpecifications - the specifications (pre/post/throws-conditions)public static java.util.List<TypedOperation> operations(ClassOrInterfaceType classType, ReflectionPredicate reflectionPredicate, OmitMethodsPredicate omitMethodsPredicate, AccessibilityPredicate accessibilityPredicate, SpecificationCollection operationSpecifications)
classType - the declaring class for collected operationsreflectionPredicate - the reflection predicateomitMethodsPredicate - the list of Pattern objects for omitting methods, may be
nullaccessibilityPredicate - the predicate for test accessibilityoperationSpecifications - the specifications (pre/post/throws-conditions)public static java.util.List<TypedOperation> operations(java.util.Collection<ClassOrInterfaceType> classTypes, ReflectionPredicate reflectionPredicate, OmitMethodsPredicate omitMethodsPredicate, AccessibilityPredicate accessibilityPredicate, SpecificationCollection operationSpecifications)
classTypes - the declaring classes for collected operationsreflectionPredicate - the reflection predicateomitMethodsPredicate - the list of Pattern objects for omitting methods, may be
nullaccessibilityPredicate - the predicate for test accessibilityoperationSpecifications - the specifications (pre/post/throws-conditions)public static java.util.List<ClassOrInterfaceType> classListToTypeList(java.util.List<java.lang.Class<?>> classes)
classes - a list of Class objectsprivate TypedClassOperation instantiateTypes(TypedClassOperation operation)
operation.getDeclaringType() is generic,
but classType is not. Constructs a Substitution that unifies the generic
declaring type with classType or a superType.operation - the operation to instantiateclassType if the declaring type is generic and
classType is not; the unmodified operation otherwiseRandoopBug - if there is no substitution that unifies the declaring type with classType or a supertypeprivate void checkSubTypes(TypedClassOperation operation)
classType of this object is a subtype of operation.getDeclaringType(); throws an exception if not.operation - the operation for which types are to be checkedRandoopBug - if field classType of this is not a subtype of operation.getDeclaringType()public void visit(java.lang.reflect.Constructor<?> constructor)
ConstructorCall object for the Constructor.visit in interface ClassVisitorvisit in class DefaultClassVisitorconstructor - a Constructor object to be represented as an Operationpublic void visit(java.lang.reflect.Method method)
MethodCall object for the Method.
The created operation has the declaring class of method as the declaring type. An
exception is a static method for which the declaring class is not public, in which case classType is used as the declaring class.
visit in interface ClassVisitorvisit in class DefaultClassVisitormethod - a Method object to be represented as an Operationpublic void visit(java.lang.reflect.Field field)
Operation objects corresponding to getters and setters appropriate to the kind
of field.visit in interface ClassVisitorvisit in class DefaultClassVisitorfield - a Field object to be represented as an Operationpublic void visit(java.lang.Enum<?> e)
EnumConstant object for the Enum.visit in interface ClassVisitorvisit in class DefaultClassVisitore - an Enum object to be represented as an Operationpublic java.util.Collection<TypedOperation> getOperations()
TypedOperation objects collected for classType.
Should be called after all members of the class are visited.