Package randoop.operation
Class CallableOperation
java.lang.Object
randoop.operation.CallableOperation
- All Implemented Interfaces:
Operation
- Direct Known Subclasses:
ArrayCreation
,ArrayElementSet
,ConstructorCall
,EnumConstant
,FieldGet
,FieldSet
,InitializedArrayCreation
,MethodCall
,NonreceiverTerm
,ReflectionArrayCreation
,UncheckedCast
CallableOperation is an abstract implementation of the Operation interface to provide default
implementations of Operation predicates that are false except for a few kinds of operations.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
appendCode
(Type declaringType, TypeTuple inputTypes, Type outputType, List<Variable> inputVars, StringBuilder b) Produces a Java source code representation of this statement and appends it to the given StringBuilder.abstract ExecutionOutcome
Performs this operation using the array of input values.(package private) String
getArgumentString
(Variable variable) Returns the variable as a string to be used as an argument to an operation.getValue()
Returns the "value" of an operation that is actually a ground term, meaning a constant of some form.boolean
Predicate to indicate whether this object represents a constant field.boolean
Predicate to indicate whether object represents a call to a constructor.boolean
Predicate to indicate whether object represents a method-call-like operation (either static or instance).boolean
Indicates whether this object represents a method-call operation (either static or instance).boolean
Predicate to indicate whether this object represents a value of a non-receiving type (includes numbers, strings, and null).boolean
isStatic()
Predicate to indicate whether object represents a static operation on the declaring class.boolean
Predicate to indicate whether this object represents an unchecked cast.boolean
satisfies
(ReflectionPredicate reflectionPredicate) Checks whether reflective object contained in anOperation
satisfies the predicate.abstract String
toParsableString
(Type declaringType, TypeTuple inputTypes, Type outputType) Returns a string representation of this Operation, which can be read by static parse method for class.
-
Constructor Details
-
CallableOperation
public CallableOperation()
-
-
Method Details
-
isStatic
public boolean isStatic()Description copied from interface:Operation
Predicate to indicate whether object represents a static operation on the declaring class. -
isMessage
public boolean isMessage()Description copied from interface:Operation
Predicate to indicate whether object represents a method-call-like operation (either static or instance). This includes field getters and setters, which are operations that access fields. -
isMethodCall
public boolean isMethodCall()Description copied from interface:Operation
Indicates whether this object represents a method-call operation (either static or instance). This excludes getters and setters.- Specified by:
isMethodCall
in interfaceOperation
- Returns:
- true if this operation is a method call, and false otherwise
-
isConstructorCall
public boolean isConstructorCall()Description copied from interface:Operation
Predicate to indicate whether object represents a call to a constructor.- Specified by:
isConstructorCall
in interfaceOperation
- Returns:
- true if operation is a constructor call, and false otherwise
-
isConstantField
public boolean isConstantField()Description copied from interface:Operation
Predicate to indicate whether this object represents a constant field.- Specified by:
isConstantField
in interfaceOperation
- Returns:
- true if this operation is a constant field, and false otherwise
-
isNonreceivingValue
public boolean isNonreceivingValue()Description copied from interface:Operation
Predicate to indicate whether this object represents a value of a non-receiving type (includes numbers, strings, and null).- Specified by:
isNonreceivingValue
in interfaceOperation
- Returns:
- true if object is a non-receiving value, and false otherwise
-
isUncheckedCast
public boolean isUncheckedCast()Description copied from interface:Operation
Predicate to indicate whether this object represents an unchecked cast.- Specified by:
isUncheckedCast
in interfaceOperation
- Returns:
- true if the this object is a cast, and false otherwise
-
getValue
Description copied from interface:Operation
Returns the "value" of an operation that is actually a ground term, meaning a constant of some form. Only null if value is null, otherwise throws an exception if there is not a reasonable meaning of value for type of operation.This is a hack to allow randoop.main.GenBranchDir to do mutation.
-
satisfies
Checks whether reflective object contained in anOperation
satisfies the predicate. Since there is no reflective object in anCallableOperation
, returns false.- Specified by:
satisfies
in interfaceOperation
- Parameters:
reflectionPredicate
-ReflectionPredicate
against which object to be checked- Returns:
- false as there is no object to check
-
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.- Parameters:
input
- array containing appropriate inputs to operation- Returns:
- results of executing this statement
-
appendCode
public abstract void appendCode(Type declaringType, TypeTuple inputTypes, Type outputType, List<Variable> inputVars, StringBuilder b) Produces a Java source code representation of this statement and appends it to the given StringBuilder.- Parameters:
declaringType
- the declaring type for this operationinputTypes
- the input types for this operationoutputType
- the output type for this operationinputVars
- the list of variables that are inputs to operationb
- theStringBuilder
to which code is added
-
getArgumentString
Returns the variable as a string to be used as an argument to an operation. Determines if the value of the variable can be given in short form. In the short output format, statements that assign to a primitive or string literal, like "int x = 3" are not added to a sequence; instead, the value (e.g. "3") is inserted directly added as arguments to method calls.- Parameters:
variable
- the variable for which the argument string is constructed- Returns:
- the argument string for the variable
-
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).- Parameters:
declaringType
- the declaring type for this operationinputTypes
- the input types for this operationoutputType
- the output type for this operation- Returns:
- a string representation of this operation
-
getReflectionObject
-