public class SpecificationCollection
extends java.lang.Object
implements java.io.Closeable
OperationSpecification objects, indexed by AccessibleObject
reflection objects. Only represents methods that have a specification.
This represents a file given on the command line via --specifications. Its purpose is
only to hold specifications temporarily, so the specification can be stored in the operation (via
TypedOperation.setExecutableSpecification(randoop.condition.ExecutableSpecification)). Once all operations have been created (and
specifications stored in them), the SpecificationCollection is discarded.
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.
| Modifier and Type | Field and Description |
|---|---|
private SequenceCompiler |
compiler
Compiler for creating conditionMethods.
|
private java.util.Map<java.lang.reflect.AccessibleObject,ExecutableSpecification> |
getExecutableSpecificationCache
|
private static com.google.gson.reflect.TypeToken<java.util.List<OperationSpecification>> |
LIST_OF_OS_TYPE_TOKEN
The type of
List<OperationSpecification>>. |
private java.util.Map<java.lang.reflect.AccessibleObject,java.util.Set<java.lang.reflect.Method>> |
overridden
Map from reflection object to all the methods it overrides (that have a specification).
|
private MultiMap<OperationSignature,java.lang.reflect.Method> |
signatureToMethods
Given a method signature, what methods (that have specifications) have that signature? Does not
contain constructors.
|
private java.util.Map<java.lang.reflect.AccessibleObject,OperationSpecification> |
specificationMap
Map from method or constructor to the corresponding
OperationSpecification. |
| Constructor and Description |
|---|
SpecificationCollection(java.util.Map<java.lang.reflect.AccessibleObject,OperationSpecification> specificationMap,
MultiMap<OperationSignature,java.lang.reflect.Method> signatureToMethods,
java.util.Map<java.lang.reflect.AccessibleObject,java.util.Set<java.lang.reflect.Method>> overridden)
Creates a
SpecificationCollection for the given specification map. |
| Modifier and Type | Method and Description |
|---|---|
private static java.util.Map<java.lang.reflect.AccessibleObject,java.util.Set<java.lang.reflect.Method>> |
buildOverridingMap(MultiMap<OperationSignature,java.lang.reflect.Method> signatureToMethods)
Constructs a map between reflection objects representing override relationships among methods.
|
void |
close()
Releases any system resources used by this.
|
static SpecificationCollection |
create(java.util.List<java.nio.file.Path> specificationFiles)
Creates a
SpecificationCollection from the list of JSON specification files. |
private static java.util.Set<java.lang.reflect.Method> |
findOverridden(java.lang.Class<?> classType,
java.util.Set<java.lang.reflect.Method> methods)
Finds the methods in
methods that are declared in a supertype of classType. |
private static java.lang.reflect.AccessibleObject |
getAccessibleObject(OperationSignature operation)
Get the
java.lang.reflect.AccessibleObject for the OperationSignature. |
ExecutableSpecification |
getExecutableSpecification(java.lang.reflect.Executable executable)
Creates an
ExecutableSpecification object for the given constructor or method, from its
specifications in this object. |
private static void |
readSpecificationFile(java.nio.file.Path specificationFile,
java.util.Map<java.lang.reflect.AccessibleObject,OperationSpecification> specificationMap,
MultiMap<OperationSignature,java.lang.reflect.Method> signatureToMethods)
Reads
OperationSpecification objects from the given file, and adds them to the other
two arguments, which are modified by side effect. |
private static void |
readSpecificationZipFile(java.nio.file.Path specificationZipFile,
java.util.Map<java.lang.reflect.AccessibleObject,OperationSpecification> specificationMap,
MultiMap<OperationSignature,java.lang.reflect.Method> signatureToMethods)
Reads
OperationSpecification objects from all the subfiles of the given zip file, and
adds them to the other two arguments, which are modified by side effect. |
private final java.util.Map<java.lang.reflect.AccessibleObject,OperationSpecification> specificationMap
OperationSpecification.private final MultiMap<OperationSignature,java.lang.reflect.Method> signatureToMethods
overridden.private final java.util.Map<java.lang.reflect.AccessibleObject,java.util.Set<java.lang.reflect.Method>> overridden
private final SequenceCompiler compiler
private static com.google.gson.reflect.TypeToken<java.util.List<OperationSpecification>> LIST_OF_OS_TYPE_TOKEN
List<OperationSpecification>>.private java.util.Map<java.lang.reflect.AccessibleObject,ExecutableSpecification> getExecutableSpecificationCache
SpecificationCollection(java.util.Map<java.lang.reflect.AccessibleObject,OperationSpecification> specificationMap, MultiMap<OperationSignature,java.lang.reflect.Method> signatureToMethods, java.util.Map<java.lang.reflect.AccessibleObject,java.util.Set<java.lang.reflect.Method>> overridden)
SpecificationCollection 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.
specificationMap - the map from method or constructor to OperationSpecificationsignatureToMethods - 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
specificationpublic static SpecificationCollection create(java.util.List<java.nio.file.Path> specificationFiles)
SpecificationCollection from the list of JSON specification files.specificationFiles - files containing serialized specificationsSpecificationCollection built from the serialized OperationSpecification objects, or null if the argument is nullpublic void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableprivate static java.util.Map<java.lang.reflect.AccessibleObject,java.util.Set<java.lang.reflect.Method>> buildOverridingMap(MultiMap<OperationSignature,java.lang.reflect.Method> signatureToMethods)
signatureToMethods - the map from a OperationSignature to methods with that
signatureAccessibleObject to methods that it overridesprivate static java.util.Set<java.lang.reflect.Method> findOverridden(java.lang.Class<?> classType,
java.util.Set<java.lang.reflect.Method> methods)
methods that are declared in a supertype of classType.
This should be called only by buildOverridingMap(randoop.util.MultiMap<randoop.condition.specification.OperationSignature, java.lang.reflect.Method>).
classType - the class whose supertypes are searchedmethods - the set of methodsmethods that are declared in a strict supertype of classTypeprivate static java.lang.reflect.AccessibleObject getAccessibleObject(OperationSignature operation)
java.lang.reflect.AccessibleObject for the OperationSignature.operation - the OperationSignaturejava.lang.reflect.AccessibleObject for operationprivate static void readSpecificationFile(java.nio.file.Path specificationFile,
java.util.Map<java.lang.reflect.AccessibleObject,OperationSpecification> specificationMap,
MultiMap<OperationSignature,java.lang.reflect.Method> signatureToMethods)
OperationSpecification objects from the given file, and adds them to the other
two arguments, which are modified by side effect.specificationFile - the JSON file of OperationSpecification objectsspecificationMap - side-effected by this methodsignatureToMethods - side-effected by this methodprivate static void readSpecificationZipFile(java.nio.file.Path specificationZipFile,
java.util.Map<java.lang.reflect.AccessibleObject,OperationSpecification> specificationMap,
MultiMap<OperationSignature,java.lang.reflect.Method> signatureToMethods)
OperationSpecification objects from all the subfiles of the given zip file, and
adds them to the other two arguments, which are modified by side effect.specificationZipFile - a zip file containing files that contain OperationSpecification objectsspecificationMap - side-effected by this methodsignatureToMethods - side-effected by this methodpublic ExecutableSpecification getExecutableSpecification(java.lang.reflect.Executable executable)
ExecutableSpecification object for the given constructor or method, from its
specifications in this object.
The translation makes the following conversions:
executable - the reflection object for a constructor or methodExecutableSpecification for the specifications of the given method or
constructor