Package randoop.operation
Class ConstructorCall
java.lang.Object
randoop.operation.CallableOperation
randoop.operation.ConstructorCall
- All Implemented Interfaces:
Operation
ConstructorCall is an
Operation
that represents a call to a constructor, and holds a
reference to a reflective Constructor
object.
As an Operation
, a call to constructor c with n arguments is represented
as c : [t1,...,tn] → c, where the output type c is also the name
of the class.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionConstructorCall
(Constructor<?> constructor) Creates object corresponding to the given reflection constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendCode
(Type declaringType, TypeTuple inputTypes, Type outputType, List<Variable> inputVars, StringBuilder b) Adds code for a constructor call to the givenStringBuilder
.boolean
Tests whether the parameter is a call to the same constructor.Performs this operation using the array of input values.Constructor<?>
Return the reflective constructor corresponding to this ConstructorCall.getName()
Returns the name for the operation.Constructor<?>
int
hashCode()
hashCode returns the hashCode for the constructor called by this object.boolean
Predicate to indicate whether object represents a call to a constructor.static TypedClassOperation
Parse a constructor call in a string with the format generated bytoParsableString(Type, TypeTuple, Type)
and returns the correspondingConstructorCall
object.boolean
satisfies
(ReflectionPredicate reflectionPredicate) Checks whether reflective object contained in anOperation
satisfies the predicate.toParsableString
(Type declaringType, TypeTuple inputTypes, Type outputType) Returns a string representation of this Operation, which can be read by static parse method for class.toString()
Returns concise string representation of this ConstructorCall.Methods inherited from class randoop.operation.CallableOperation
getArgumentString, getValue, isConstantField, isMessage, isMethodCall, isNonreceivingValue, isStatic, isUncheckedCast
-
Field Details
-
constructor
-
hashCodeCached
private int hashCodeCached -
hashCodeComputed
private boolean hashCodeComputed
-
-
Constructor Details
-
ConstructorCall
Creates object corresponding to the given reflection constructor.- Parameters:
constructor
- reflective object for a constructor
-
-
Method Details
-
getConstructor
Return the reflective constructor corresponding to this ConstructorCall.- Returns:
Constructor
object called by this constructor call
-
toString
Returns concise string representation of this ConstructorCall. -
getName
Description copied from interface:Operation
Returns the name for the operation.- Returns:
- the name for this operation
-
appendCode
public void appendCode(Type declaringType, TypeTuple inputTypes, Type outputType, List<Variable> inputVars, StringBuilder b) Adds code for a constructor call to the givenStringBuilder
.- Specified by:
appendCode
in classCallableOperation
- Parameters:
inputVars
- a list of variables representing the actual arguments for the constructor callb
- the StringBuilder to which the output is appendeddeclaringType
- the declaring type for this operationinputTypes
- the input types for this operationoutputType
- the output type for this operation- See Also:
-
equals
Tests whether the parameter is a call to the same constructor. -
hashCode
public int hashCode()hashCode returns the hashCode for the constructor called by this object. -
execute
Performs this operation using the array of input values. Returns the results of execution as an ResultOrException object and can output results to specified PrintStream.Performs call to the constructor given the objects as actual parameters, and the output stream for any output.
- Specified by:
execute
in classCallableOperation
- Parameters:
statementInput
- is an array of values corresponding to signature of the constructor- Returns:
- results of executing this statement
- See Also:
-
toParsableString
Returns a string representation of this Operation, which can be read by static parse method for 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).Generates a string representation of the constructor signature.
Examples:
java.util.ArrayList.<init>() java.util.ArrayList.<init>(java.util.Collection)
- Specified by:
toParsableString
in classCallableOperation
- Parameters:
declaringType
- the declaring type for this operationinputTypes
- the input types for this operationoutputType
- the output type for this operation- Returns:
- signature string for constructor
- See Also:
-
parse
Parse a constructor call in a string with the format generated bytoParsableString(Type, TypeTuple, Type)
and returns the correspondingConstructorCall
object.- Parameters:
signature
- a string descriptor of a constructor call- Returns:
- the constructor call for the given string descriptor
- Throws:
OperationParseException
- if no constructor found for signature- See Also:
-
isConstructorCall
public boolean isConstructorCall()Predicate to indicate whether object represents a call to a constructor.- Specified by:
isConstructorCall
in interfaceOperation
- Overrides:
isConstructorCall
in classCallableOperation
- Returns:
- true, because this is a
ConstructorCall
-
getReflectionObject
- Overrides:
getReflectionObject
in classCallableOperation
-
satisfies
Checks whether reflective object contained in anOperation
satisfies the predicate. Since there is no reflective object in anCallableOperation
, returns false.Determines whether enclosed
Constructor
satisfies the given predicate.- Specified by:
satisfies
in interfaceOperation
- Overrides:
satisfies
in classCallableOperation
- Parameters:
reflectionPredicate
-ReflectionPredicate
against which object to be checked- Returns:
- true only if the constructor in this object satisfies the
ReflectionPredicate.test(Constructor)
implemented by predicate.
-