class HelperSequenceCreator
extends java.lang.Object
The only two methods that are currently externally used are createArraySequence(randoop.generation.ComponentManager, randoop.types.Type) and
createCollection(randoop.generation.ComponentManager, randoop.types.InstantiatedType).
| Modifier and Type | Class and Description |
|---|---|
private static interface |
HelperSequenceCreator.SequenceExtender |
| Modifier | Constructor and Description |
|---|---|
private |
HelperSequenceCreator() |
| Modifier and Type | Method and Description |
|---|---|
private static Sequence |
buildAddSequence(Sequence creationSequence,
TupleSequence elementsSequence,
HelperSequenceCreator.SequenceExtender addSequenceExtender)
Returns a sequence that creates a list or array.
|
private static Sequence |
createAnArray(TupleSequence elementsSequence,
Type elementType,
int length)
Creates a sequence that builds an array of the given element type using sequences from the
given list of candidates.
|
(package private) static SimpleList<Sequence> |
createArraySequence(ComponentManager components,
Type collectionType)
Returns a sequence that creates an object of type compatible with the given class.
|
(package private) static Sequence |
createCollection(ComponentManager componentManager,
InstantiatedType collectionType)
Generates a sequence that creates a Collection.
|
private static Sequence |
createCollectionCreationSequence(InstantiatedType implementingType,
ReferenceType elementType)
Creates the creation sequence for a collection with the given type and element type.
|
private static Sequence |
createGenericArrayCreationSequence(ArrayType arrayType,
int length)
Creates a
Sequence for creating an array with parameterized type. |
private static TypedOperation |
getAddOperation(ParameterizedType collectionType,
ReferenceType elementType)
Create a method call operation for the
add() method of the given collection type. |
private static TypedOperation |
getCollectionAddAllOperation(ReferenceType elementType)
Create the operation to call
Collections.addAll(Collection, Object[]) that
allows initialization of a Collection object. |
private static java.lang.reflect.Constructor<?> |
getDefaultConstructor(ClassOrInterfaceType creationType)
Gets the default constructor for a
ClassOrInterfaceType. |
private static ReferenceType |
getElementType(InstantiatedType collectionType)
Returns the element type of the given collection type.
|
private static TypedOperation |
getEnumSetCreation(ParameterizedType creationType)
Create the operation needed to create an empty EnumSet of the given type.
|
private static InstantiatedType |
getImplementingTypeForCollection(InstantiatedType elementType)
Constructs an implementing type for an abstract subtype of
java.util.Collection using
the JDKTypes.getImplementingTypeForCollection(ParameterizedType) method. |
static SimpleList<Sequence> createArraySequence(ComponentManager components, Type collectionType)
CURRENTLY, will return a sequence (i.e. a non-empty list) only if collectionType is
an array.
components - the component manager with existing sequencescollectionType - the query typeprivate static ReferenceType getElementType(InstantiatedType collectionType)
collectionType - the collection typestatic Sequence createCollection(ComponentManager componentManager, InstantiatedType collectionType)
componentManager - the component manager for selecting valuescollectionType - the type for collectioncollectionTypeprivate static Sequence buildAddSequence(Sequence creationSequence, TupleSequence elementsSequence, HelperSequenceCreator.SequenceExtender addSequenceExtender)
creationSequence - creates an empty array or listelementsSequence - a tuple-producing sequence; produces the elements of the resultaddSequenceExtender - creates a[i]=e (for an array) or l.add(e) (for a
list)private static Sequence createCollectionCreationSequence(InstantiatedType implementingType, ReferenceType elementType)
implementingType - the collection typeelementType - the type of the elementsSequence that creates a collection of implementingTypeprivate static Sequence createAnArray(TupleSequence elementsSequence, Type elementType, int length)
elementsSequence - the sequence creating element valueselementType - the type of elements for the arraylength - the length of the arrayprivate static Sequence createGenericArrayCreationSequence(ArrayType arrayType, int length)
Sequence for creating an array with parameterized type. Resulting code looks
like (ElementType[])new RawElementType[dim0]. Note that the SuppressWarnings
annotation is added when the assignment with the cast is output.arrayType - the type of the arraylength - the length of the array to be createdprivate static java.lang.reflect.Constructor<?> getDefaultConstructor(ClassOrInterfaceType creationType)
ClassOrInterfaceType. Returns null if the type has
none.creationType - the class typeprivate static InstantiatedType getImplementingTypeForCollection(InstantiatedType elementType)
java.util.Collection using
the JDKTypes.getImplementingTypeForCollection(ParameterizedType) method. Otherwise,
returns the given type.
Note: this should ensure that the type has some mechanism for constructing an object
elementType - the typeprivate static TypedOperation getEnumSetCreation(ParameterizedType creationType)
creationType - the EnumSet typeprivate static TypedOperation getAddOperation(ParameterizedType collectionType, ReferenceType elementType)
add() method of the given collection type.collectionType - the collection typeelementType - the element type of the collectionprivate static TypedOperation getCollectionAddAllOperation(ReferenceType elementType)
Collections.addAll(Collection, Object[]) that
allows initialization of a Collection object.elementType - the element type of the collection