public final class NonreceiverTerm extends CallableOperation
Operation
.
As an Operation
, a value v of type T is formally represented by an operation v : []
→ T, with no input types, and the type of the value as the output type. This kind of
operation is a ground term that requires no inputs.
The execution of this Operation
simply returns the value.
Modifier and Type | Field and Description |
---|---|
private Type |
type
The
Type of this non-receiver term. |
private @Nullable java.lang.Object |
value
The value of this non-receiver term.
|
Constructor and Description |
---|
NonreceiverTerm(Type type,
java.lang.Object value)
Constructs a NonreceiverTerm.
|
Modifier and Type | Method and Description |
---|---|
void |
appendCode(Type declaringType,
TypeTuple inputTypes,
Type outputType,
java.util.List<Variable> inputVars,
java.lang.StringBuilder b)
Produces a Java source code representation of this statement and appends it to the given
StringBuilder.
|
(package private) static NonreceiverTerm |
createNullOrZeroTerm(Type type)
Returns a NonreceiverTerm holding the zero/false value for the specified class c.
|
boolean |
equals(@Nullable java.lang.Object o)
Indicates whether this object is equal to o.
|
ExecutionOutcome |
execute(java.lang.Object[] statementInput)
Performs this operation using the array of input values.
|
java.lang.String |
getName()
Returns the name for the operation.
|
Type |
getType()
Return the type.
|
java.lang.Object |
getValue()
Returns the "value" of an operation that is actually a ground term, meaning a constant of some
form.
|
int |
hashCode()
Returns a hash code value for this NonreceiverTerm.
|
static boolean |
isNonreceiverType(java.lang.Class<?> c)
Determines whether the given
Class<?> is the type of a non-receiver term. |
boolean |
isNonreceivingValue()
Predicate to indicate whether this object represents a value of a non-receiving type (includes
numbers, strings, and null).
|
static TypedOperation |
parse(java.lang.String s)
Parse a non-receiver value in a string in the form generated by
toParsableString(Type, TypeTuple, Type) |
java.lang.String |
toParsableString(Type declaringType,
TypeTuple inputTypes,
Type outputType)
Returns a string representation of this Operation (not an invocation of this Operation), which
can be read by the static parse method for the class in which the method is defined.
|
java.lang.String |
toString()
Returns string representation of this NonreceiverTerm.
|
getArgumentString, getReflectionObject, isConstantField, isConstructorCall, isMessage, isMethodCall, isStatic, isUncheckedCast, satisfies
private final @Nullable java.lang.Object value
public NonreceiverTerm(Type type, java.lang.Object value)
type
- the type of the termvalue
- the value of the termpublic static boolean isNonreceiverType(java.lang.Class<?> c)
Class<?>
is the type of a non-receiver term.c
- the Class<?>
objectString
, or Class
public boolean equals(@Nullable java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getName()
Operation
public ExecutionOutcome execute(java.lang.Object[] statementInput)
execute
in class CallableOperation
statementInput
- array containing appropriate inputs to operationNormalExecution
object enclosing value of this non-receiver termpublic void appendCode(Type declaringType, TypeTuple inputTypes, Type outputType, java.util.List<Variable> inputVars, java.lang.StringBuilder b)
For NonreceiverTerm, simply adds a code representation of the value to the string builder. Note: this does not explicitly box primitive values.
appendCode
in class CallableOperation
inputVars
- ignoredb
- StringBuilder
to which string representation is appendeddeclaringType
- the declaring type for this operationinputTypes
- the input types for this operationoutputType
- the output type for this operationpublic java.lang.Object getValue()
This is a hack to allow randoop.main.GenBranchDir to do mutation.
getValue
in interface Operation
getValue
in class CallableOperation
NonreceiverTerm
public Type getType()
static NonreceiverTerm createNullOrZeroTerm(Type type)
JavaTypes.CLASS_TYPE
.
JavaTypes.STRING_TYPE
.
type
- the type of value desiredNonreceiverTerm
with a canonical representative of the given typepublic java.lang.String toParsableString(Type declaringType, TypeTuple inputTypes, Type outputType)
Returns a string representing this primitive declaration. The string is of the form:
TYPE:VALUE
Where TYPE is the type of the primitive declaration, and VALUE is its value. If VALUE is "null"
then the value is null (not the String "null"). If TYPE is "char" then
(char)Integer.parseInt(VALUE, 16) yields the character value.
Examples:
String:null represents: String x = null java.lang.String:"" represents: String x = ""; String:"" represents: String x = ""; String:" " represents: String x = " "; String:"\"" represents: String x = "\""; String:"\n" represents: String x = "\n"; String:"☺" represents: String x = "☺"; java.lang.Object:null represents: Object x = null; [[Ljava.lang.Object;:null represents: Object[][] = null; int:0 represents: int x = 0; boolean:false represents: boolean x = false; char:20 represents: char x = ' ';Note that a string type can be given as both "String" or "java.lang.String".
toParsableString
in class CallableOperation
declaringType
- the declaring type for this operationinputTypes
- the input types for this operationoutputType
- the output type for this operationpublic static TypedOperation parse(java.lang.String s) throws OperationParseException
toParsableString(Type, TypeTuple, Type)
s
- a string representing a value of a non-receiver typeOperationParseException
- if string does not represent valid objectpublic boolean isNonreceivingValue()
isNonreceivingValue
in interface Operation
isNonreceivingValue
in class CallableOperation