Package randoop.operation
Class UncheckedCast
java.lang.Object
randoop.operation.CallableOperation
randoop.operation.UncheckedCast
- All Implemented Interfaces:
Operation
An
Operation
to perform an explicit cast. NOTE: there is no actual checking of the types
being done. This operation is only used in contexts where the cast is known to be unchecked.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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.Performs this operation using the array of input values.getName()
Returns the name for the operation.boolean
Predicate to indicate whether this object represents an unchecked cast.toParsableString
(Type declaringType, TypeTuple inputTypes, Type outputType) Returns a string representation of this Operation, which can be read by static parse method for class.Methods inherited from class randoop.operation.CallableOperation
getArgumentString, getReflectionObject, getValue, isConstantField, isConstructorCall, isMessage, isMethodCall, isNonreceivingValue, isStatic, satisfies
-
Field Details
-
type
The result type of the cast.
-
-
Constructor Details
-
UncheckedCast
UncheckedCast(Type type) Creates an operation that performs a cast. Intended for use in generated sequences where an unchecked cast is needed.- Parameters:
type
- the cast type
-
-
Method Details
-
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 this cast on the first value of the input array.
- Specified by:
execute
in classCallableOperation
- Parameters:
input
- array containing appropriate inputs to operation- Returns:
- the value cast to the type of this cast
-
appendCode
public 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.Appends the code for this cast applied to the given input to the given
StringBuilder
.- Specified by:
appendCode
in classCallableOperation
- 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
-
isUncheckedCast
public boolean isUncheckedCast()Description copied from interface:Operation
Predicate to indicate whether this object represents an unchecked cast.- Specified by:
isUncheckedCast
in interfaceOperation
- Overrides:
isUncheckedCast
in classCallableOperation
- Returns:
- true if the this object is a cast, and false otherwise
-
toParsableString
Description copied from class:CallableOperation
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).- 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:
- a string representation of this operation
-
getName
Description copied from interface:Operation
Returns the name for the operation.- Returns:
- the name for this operation
-