Package randoop.operation
Class TypedClassOperation
java.lang.Object
randoop.operation.TypedOperation
randoop.operation.TypedClassOperation
- All Implemented Interfaces:
Comparable<TypedOperation>
,Operation
- Direct Known Subclasses:
TypedClassOperationWithCast
Represents a TypedOperation and its declaring class. Examples of TypedOperations that have a
declaring class are a method call or field access.
-
Nested Class Summary
Nested classes/interfaces inherited from class randoop.operation.TypedOperation
TypedOperation.RankedTypeOperation
-
Field Summary
Modifier and TypeFieldDescriptionprivate final ClassOrInterfaceType
The declaring type for this operation.private RawSignature
The cached value ofgetRawSignature()
.Fields inherited from class randoop.operation.TypedOperation
compareRankedTypeOperation, inputTypes
-
Constructor Summary
ConstructorDescriptionTypedClassOperation
(CallableOperation operation, ClassOrInterfaceType declaringType, TypeTuple inputTypes, Type outputType) Creates aTypedClassOperation
for a givenCallableOperation
indicating the signature of the operation.TypedClassOperation
(CallableOperation operation, ClassOrInterfaceType declaringType, TypeTuple inputTypes, Type outputType, ExecutableSpecification execSpec) Creates aTypedClassOperation
for a givenCallableOperation
indicating the signature of the operation. -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendCode
(List<Variable> inputVars, StringBuilder b) Produces a Java source code representation of this operation and appends it to the given StringBuilder.Applies a capture conversion to the wildcard types of this operation, and returns a new operation with new type variables for the wildcard types.boolean
Returns the class in which the operation is defined.Returns the fully-qualified signature for this operation if it is a method or constructor call.getName()
Returns the name for the operation.Creates an operation with the same name, input types, and output type as this operation, but having the given type as the owning class.Returns theRawSignature
for this operation if it is a method or constructor call.Returns an empty list representing the type parameters of this.Returns the simple name of this operation, not qualified by the declaring class.int
hashCode()
boolean
Indicates whether this operation has a type that is a wildcard type.substitute
(Substitution substitution) Applies the given substitution to the generic types in this operation, and returns a new operation with the instantiated types.Returns a string representation of this Operation, which can be read by the staticparse
method for an Operation class.toString()
Methods inherited from class randoop.operation.TypedOperation
checkPrestate, compareTo, createArrayCreation, createArrayElementAssignment, createCast, createGetterForField, createInitializedArrayCreation, createNonreceiverInitialization, createNullOrZeroInitializationForType, createPrimitiveInitialization, createSetterForField, execute, forConstructor, forMethod, getExecutableSpecification, getInputTypes, getOperation, getOutputType, getSignatureString, getValue, isConstantField, isConstructorCall, isGeneric, isGeneric, isMessage, isMethodCall, isNonreceivingValue, isStatic, isUncheckedCast, satisfies, setExecutableSpecification
-
Field Details
-
declaringType
The declaring type for this operation. -
rawSignature
The cached value ofgetRawSignature()
.
-
-
Constructor Details
-
TypedClassOperation
public TypedClassOperation(CallableOperation operation, ClassOrInterfaceType declaringType, TypeTuple inputTypes, Type outputType) Creates aTypedClassOperation
for a givenCallableOperation
indicating the signature of the operation.- Parameters:
operation
- theCallableOperation
declaringType
- the declaring class type for this operationinputTypes
- the input types for the operationoutputType
- the output types for the operation
-
TypedClassOperation
public TypedClassOperation(CallableOperation operation, ClassOrInterfaceType declaringType, TypeTuple inputTypes, Type outputType, ExecutableSpecification execSpec) Creates aTypedClassOperation
for a givenCallableOperation
indicating the signature of the operation.- Parameters:
operation
- theCallableOperation
declaringType
- the declaring class type for this operationinputTypes
- the input types for the operationoutputType
- the output types for the operationexecSpec
- the specification for the operation
-
-
Method Details
-
equals
- Overrides:
equals
in classTypedOperation
-
hashCode
public int hashCode()- Overrides:
hashCode
in classTypedOperation
-
getDeclaringType
Returns the class in which the operation is defined.- Returns:
- class to which the operation belongs
-
substitute
Applies the given substitution to the generic types in this operation, and returns a new operation with the instantiated types.Applies the substitution to the declaring type, all input types, and the output type.
- Specified by:
substitute
in classTypedOperation
- Parameters:
substitution
- the substitution- Returns:
- the operation resulting from applying the substitution to the types of this operation
-
applyCaptureConversion
Description copied from class:TypedOperation
Applies a capture conversion to the wildcard types of this operation, and returns a new operation with new type variables for the wildcard types.- Specified by:
applyCaptureConversion
in classTypedOperation
- Returns:
- the operation result from applying a capture conversion to wildcard types of this operation
-
appendCode
Produces a Java source code representation of this operation and appends it to the given StringBuilder.- Specified by:
appendCode
in classTypedOperation
- Parameters:
inputVars
- the list of variables that are inputs to operationb
- theStringBuilder
to which code is added
-
toParsableString
Returns a string representation of this Operation, which can be read by the staticparse
method for an Operation class. For a class C implementing the Operation interface, this method should return a String s such that parsing the string returns an object equivalent to this object, i.e., C.parse(this.s).equals(this).- Specified by:
toParsableString
in classTypedOperation
- Returns:
- string descriptor of
Operation
object
-
toString
- Overrides:
toString
in classTypedOperation
-
getName
Description copied from interface:Operation
Returns the name for the operation.- Specified by:
getName
in interfaceOperation
- Overrides:
getName
in classTypedOperation
- Returns:
- the name for this operation
-
getUnqualifiedBinaryName
Returns the simple name of this operation, not qualified by the declaring class.- Returns:
- the unqualified name of this operation
-
hasWildcardTypes
public boolean hasWildcardTypes()Description copied from class:TypedOperation
Indicates whether this operation has a type that is a wildcard type.- Specified by:
hasWildcardTypes
in classTypedOperation
- Returns:
- true if at least one input or output type has a wildcard, false otherwise
-
getTypeParameters
Description copied from class:TypedOperation
Returns an empty list representing the type parameters of this. Clients will mutate the list.- Overrides:
getTypeParameters
in classTypedOperation
- Returns:
- an empty list representing the type parameters of this
-
getFullyQualifiedSignature
Returns the fully-qualified signature for this operation if it is a method or constructor call.- Returns:
- this operation's fully qualified signature if it is a method or constructor call, null otherwise
-
getRawSignature
Returns theRawSignature
for this operation if it is a method or constructor call.- Returns:
- the
RawSignature
of this method or constructor operation, null if this is another kind of operation
-
getOperationForType
Creates an operation with the same name, input types, and output type as this operation, but having the given type as the owning class.Note: this is only a valid object if
type
has the method. This is definitely the case iftype
is a subtype of the declaring type of the operation, but this method does not force that check because we sometimes want to create the operation for superclasses.- Parameters:
type
- a type to substitute into the operation- Returns:
- an operation with
type
substituted for the declaring type of this operation. The returned object will be invalid iftype
does not have the method. The returned object may bethis
, if the argument is alreadythis
's declaring type.
-