Package randoop.condition
Class SpecificationCollection
java.lang.Object
randoop.condition.SpecificationCollection
- All Implemented Interfaces:
Closeable
,AutoCloseable
A collection of
OperationSpecification
objects, indexed by AccessibleObject
reflection objects. Only represents methods that have a specification.
The SpecificationCollection
should be constructed from the specification input before
the OperationModel
is created.
This class stores the OperationSpecification
objects, and only constructs the
corresponding ExecutableSpecification
on demand. This lazy strategy avoids building
condition methods for specifications that are not used.
-
Field Summary
Modifier and TypeFieldDescriptionprivate final SequenceCompiler
Compiler for creating conditionMethods.private Map<AccessibleObject,
ExecutableSpecification> private static com.google.gson.reflect.TypeToken<List<OperationSpecification>>
The type ofList<OperationSpecification>>
.private final Map<AccessibleObject,
Set<Method>> Map from reflection object to all the methods it overrides (that have a specification).private final MultiMap<OperationSignature,
Method> Given a method signature, what methods (that have specifications) have that signature? Does not contain constructors.private final Map<AccessibleObject,
OperationSpecification> Map from method or constructor to the correspondingOperationSpecification
. -
Constructor Summary
ConstructorDescriptionSpecificationCollection
(Map<AccessibleObject, OperationSpecification> specificationMap, MultiMap<OperationSignature, Method> signatureToMethods, Map<AccessibleObject, Set<Method>> overridden) Creates aSpecificationCollection
for the given specification map. -
Method Summary
Modifier and TypeMethodDescriptionprivate static Map<AccessibleObject,
Set<Method>> buildOverridingMap
(MultiMap<OperationSignature, Method> signatureToMethods) Constructs a map between reflection objects representing override relationships among methods.void
close()
Releases any system resources used by this.static SpecificationCollection
Creates aSpecificationCollection
from the list of JSON specification files.findOverridden
(Class<?> classType, Set<Method> methods) Finds the methods inmethods
that are declared in a supertype ofclassType
.private static AccessibleObject
getAccessibleObject
(OperationSignature operation) Get thejava.lang.reflect.AccessibleObject
for theOperationSignature
.getExecutableSpecification
(Executable executable) Creates anExecutableSpecification
object for the given constructor or method, from its specifications in this object.private static void
readSpecificationFile
(Path specificationFile, Map<AccessibleObject, OperationSpecification> specificationMap, MultiMap<OperationSignature, Method> signatureToMethods) ReadsOperationSpecification
objects from the given file, and adds them to the other two arguments, which are modified by side effect.private static void
readSpecificationZipFile
(Path specificationZipFile, Map<AccessibleObject, OperationSpecification> specificationMap, MultiMap<OperationSignature, Method> signatureToMethods) ReadsOperationSpecification
objects from all the subfiles of the given zip file, and adds them to the other two arguments, which are modified by side effect.
-
Field Details
-
specificationMap
Map from method or constructor to the correspondingOperationSpecification
. -
signatureToMethods
Given a method signature, what methods (that have specifications) have that signature? Does not contain constructors. -
overridden
Map from reflection object to all the methods it overrides (that have a specification). -
compiler
Compiler for creating conditionMethods. -
LIST_OF_OS_TYPE_TOKEN
private static com.google.gson.reflect.TypeToken<List<OperationSpecification>> LIST_OF_OS_TYPE_TOKENThe type ofList<OperationSpecification>>
. -
getExecutableSpecificationCache
-
-
Constructor Details
-
SpecificationCollection
SpecificationCollection(Map<AccessibleObject, OperationSpecification> specificationMap, MultiMap<OperationSignature, Method> signatureToMethods, Map<AccessibleObject, Set<Method>> overridden) Creates aSpecificationCollection
for the given specification map.This constructor is used internally. It is only accessible (package-protected) to allow testing. Clients should use
create(List)
instead.- Parameters:
specificationMap
- the map from method or constructor toOperationSpecification
signatureToMethods
- the multimap from a signature to methods with with the signatureoverridden
- the map from a method to methods that it overrides and that have a specification
-
-
Method Details
-
create
Creates aSpecificationCollection
from the list of JSON specification files.- Parameters:
specificationFiles
- files containing serialized specifications- Returns:
- the
SpecificationCollection
built from the serializedOperationSpecification
objects, or null if the argument is null
-
close
public void close()Releases any system resources used by this.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
buildOverridingMap
private static Map<AccessibleObject,Set<Method>> buildOverridingMap(MultiMap<OperationSignature, Method> signatureToMethods) Constructs a map between reflection objects representing override relationships among methods.- Parameters:
signatureToMethods
- the map from aOperationSignature
to methods with that signature- Returns:
- the map from an
AccessibleObject
to methods that it overrides
-
findOverridden
Finds the methods inmethods
that are declared in a supertype ofclassType
.This should be called only by
buildOverridingMap(randoop.util.MultiMap<randoop.condition.specification.OperationSignature, java.lang.reflect.Method>)
.- Parameters:
classType
- the class whose supertypes are searchedmethods
- the set of methods- Returns:
- the elements of
methods
that are declared in a strict supertype ofclassType
-
getAccessibleObject
Get thejava.lang.reflect.AccessibleObject
for theOperationSignature
.- Parameters:
operation
- theOperationSignature
- Returns:
- the
java.lang.reflect.AccessibleObject
foroperation
-
readSpecificationFile
private static void readSpecificationFile(Path specificationFile, Map<AccessibleObject, OperationSpecification> specificationMap, MultiMap<OperationSignature, Method> signatureToMethods) ReadsOperationSpecification
objects from the given file, and adds them to the other two arguments, which are modified by side effect.- Parameters:
specificationFile
- the JSON file ofOperationSpecification
objectsspecificationMap
- side-effected by this methodsignatureToMethods
- side-effected by this method
-
readSpecificationZipFile
private static void readSpecificationZipFile(Path specificationZipFile, Map<AccessibleObject, OperationSpecification> specificationMap, MultiMap<OperationSignature, Method> signatureToMethods) ReadsOperationSpecification
objects from all the subfiles of the given zip file, and adds them to the other two arguments, which are modified by side effect.- Parameters:
specificationZipFile
- a zip file containing files that containOperationSpecification
objectsspecificationMap
- side-effected by this methodsignatureToMethods
- side-effected by this method
-
getExecutableSpecification
Creates anExecutableSpecification
object for the given constructor or method, from its specifications in this object.The translation makes the following conversions:
- Parameters:
executable
- the reflection object for a constructor or method- Returns:
- the
ExecutableSpecification
for the specifications of the given method or constructor
-