Class OperationExtractor

    • Field Detail

      • debug

        private static boolean debug
        Whether to produce debugging output to the Randoop log.
      • classType

        private ClassOrInterfaceType classType
        The type of the declaring class for the collected operations.
      • operations

        private final Collection<TypedOperation> operations
        The operations collected by the extractor. This is the product of applying the visitor.
      • reflectionPredicate

        private final ReflectionPredicate reflectionPredicate
        The reflection policy for collecting operations.
      • omitPredicate

        private OmitMethodsPredicate omitPredicate
        The predicate to test whether to omit an operation.
      • accessibilityPredicate

        private final AccessibilityPredicate accessibilityPredicate
        The predicate to test accessibility.
      • operationSpecifications

        private final SpecificationCollection operationSpecifications
        The specifications (pre/post/throws-conditions).
    • Constructor Detail

      • OperationExtractor

        public 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.

        Once created this visitor should only be applied to members of classType.getRuntimeType().

        Parameters:
        classType - the declaring class for collected operations
        reflectionPredicate - the reflection predicate
        omitPredicate - the list of Pattern objects for omitting methods, may be null
        accessibilityPredicate - the predicate for test accessibility
        operationSpecifications - the specifications (pre/post/throws-conditions)
      • OperationExtractor

        public 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.
        Parameters:
        classType - the declaring class for collected operations
        reflectionPredicate - the reflection predicate
        accessibilityPredicate - the predicate for test accessibility
      • OperationExtractor

        public 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.
        Parameters:
        classType - the declaring class for collected operations
        reflectionPredicate - the reflection predicate
        omitPredicate - the list of Pattern objects for omitting methods, may be null
        accessibilityPredicate - the predicate for test accessibility
    • Method Detail

      • operations

        public static List<TypedOperation> operations​(Class<?> clazz,
                                                      ReflectionPredicate reflectionPredicate,
                                                      AccessibilityPredicate accessibilityPredicate)
        Returns the operations in the class that satisfy the given predicates.
        Parameters:
        clazz - the declaring class for collected operations
        reflectionPredicate - the reflection predicate
        accessibilityPredicate - the predicate for test accessibility
        Returns:
        the operations in the class that sastisfy the given predicates
      • operations

        public static List<TypedOperation> operations​(ClassOrInterfaceType classType,
                                                      ReflectionPredicate reflectionPredicate,
                                                      AccessibilityPredicate accessibilityPredicate)
        Returns the operations in the class that satisfy the given predicates.
        Parameters:
        classType - the declaring class for collected operations
        reflectionPredicate - the reflection predicate
        accessibilityPredicate - the predicate for test accessibility
        Returns:
        the operations in the class that sastisfy the given predicates
      • operations

        public static List<TypedOperation> operations​(Collection<ClassOrInterfaceType> classTypes,
                                                      ReflectionPredicate reflectionPredicate,
                                                      AccessibilityPredicate accessibilityPredicate)
        Returns the operations in the class that satisfy the given predicates.
        Parameters:
        classTypes - the declaring classes for collected operations
        reflectionPredicate - the reflection predicate
        accessibilityPredicate - the predicate for test accessibility
        Returns:
        the operations in the class that sastisfy the given predicates
      • operations

        public static List<TypedOperation> operations​(Class<?> clazz,
                                                      ReflectionPredicate reflectionPredicate,
                                                      OmitMethodsPredicate omitPredicate,
                                                      AccessibilityPredicate accessibilityPredicate)
        Returns the operations in the class that satisfy the given predicates.
        Parameters:
        clazz - the declaring class for collected operations
        reflectionPredicate - the reflection predicate
        omitPredicate - the list of Pattern objects for omitting methods, may be null
        accessibilityPredicate - the predicate for test accessibility
        Returns:
        the operations in the class that sastisfy the given predicates
      • operations

        public static List<TypedOperation> operations​(ClassOrInterfaceType classType,
                                                      ReflectionPredicate reflectionPredicate,
                                                      OmitMethodsPredicate omitPredicate,
                                                      AccessibilityPredicate accessibilityPredicate)
        Returns the operations in the class that satisfy the given predicates.
        Parameters:
        classType - the declaring class for collected operations
        reflectionPredicate - the reflection predicate
        omitPredicate - the list of Pattern objects for omitting methods, may be null
        accessibilityPredicate - the predicate for test accessibility
        Returns:
        the operations in the class that sastisfy the given predicates
      • operations

        public static List<TypedOperation> operations​(Collection<ClassOrInterfaceType> classTypes,
                                                      ReflectionPredicate reflectionPredicate,
                                                      OmitMethodsPredicate omitPredicate,
                                                      AccessibilityPredicate accessibilityPredicate)
        Returns the operations in the class that satisfy the given predicates.
        Parameters:
        classTypes - the declaring classes for collected operations
        reflectionPredicate - the reflection predicate
        omitPredicate - the list of Pattern objects for omitting methods, may be null
        accessibilityPredicate - the predicate for test accessibility
        Returns:
        the operations in the class that sastisfy the given predicates
      • operations

        public static List<TypedOperation> operations​(Class<?> clazz,
                                                      ReflectionPredicate reflectionPredicate,
                                                      OmitMethodsPredicate omitMethodsPredicate,
                                                      AccessibilityPredicate accessibilityPredicate,
                                                      SpecificationCollection operationSpecifications)
        Returns the operations in the class that satisfy the given predicates.
        Parameters:
        clazz - the declaring class for collected operations
        reflectionPredicate - the reflection predicate
        omitMethodsPredicate - the list of Pattern objects for omitting methods, may be null
        accessibilityPredicate - the predicate for test accessibility
        operationSpecifications - the specifications (pre/post/throws-conditions)
        Returns:
        the operations in the class that sastisfy the given predicates
      • operations

        public static List<TypedOperation> operations​(ClassOrInterfaceType classType,
                                                      ReflectionPredicate reflectionPredicate,
                                                      OmitMethodsPredicate omitMethodsPredicate,
                                                      AccessibilityPredicate accessibilityPredicate,
                                                      SpecificationCollection operationSpecifications)
        Returns the operations in the class that satisfy the given predicates.
        Parameters:
        classType - the declaring class for collected operations
        reflectionPredicate - the reflection predicate
        omitMethodsPredicate - the list of Pattern objects for omitting methods, may be null
        accessibilityPredicate - the predicate for test accessibility
        operationSpecifications - the specifications (pre/post/throws-conditions)
        Returns:
        the operations in the class that sastisfy the given predicates
      • operations

        public static List<TypedOperation> operations​(Collection<ClassOrInterfaceType> classTypes,
                                                      ReflectionPredicate reflectionPredicate,
                                                      OmitMethodsPredicate omitMethodsPredicate,
                                                      AccessibilityPredicate accessibilityPredicate,
                                                      SpecificationCollection operationSpecifications)
        Returns the operations in the class that satisfy the given predicates.
        Parameters:
        classTypes - the declaring classes for collected operations
        reflectionPredicate - the reflection predicate
        omitMethodsPredicate - the list of Pattern objects for omitting methods, may be null
        accessibilityPredicate - the predicate for test accessibility
        operationSpecifications - the specifications (pre/post/throws-conditions)
        Returns:
        the operations in the class that sastisfy the given predicates
      • classListToTypeList

        public static List<ClassOrInterfaceType> classListToTypeList​(List<Class<?>> classes)
        Converts a list of classes to a list of ClassOrInterfaceType.
        Parameters:
        classes - a list of Class objects
        Returns:
        a list of ClassOrInterfaceType objects
      • instantiateTypes

        private TypedClassOperation instantiateTypes​(TypedClassOperation operation)
        Updates the operation types in the case that operation.getDeclaringType() is generic, but classType is not. Constructs a Substitution that unifies the generic declaring type with classType or a superType.
        Parameters:
        operation - the operation to instantiate
        Returns:
        operation instantiated to match classType if the declaring type is generic and classType is not; the unmodified operation otherwise
        Throws:
        RandoopBug - if there is no substitution that unifies the declaring type with classType or a supertype
      • checkSubTypes

        private void checkSubTypes​(TypedClassOperation operation)
        Ensures that field classType of this object is a subtype of operation.getDeclaringType(); throws an exception if not.
        Parameters:
        operation - the operation for which types are to be checked
        Throws:
        RandoopBug - if field classType of this is not a subtype of operation.getDeclaringType()
      • visit

        public void visit​(Method method)
        Creates a 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.

        Specified by:
        visit in interface ClassVisitor
        Overrides:
        visit in class DefaultClassVisitor
        Parameters:
        method - a Method object to be represented as an Operation
      • getOperations

        public Collection<TypedOperation> getOperations()
        Returns the TypedOperation objects collected for classType.

        Should be called after all members of the class are visited.

        Returns:
        the collection of operations collected for the class