public interface Operation
The concept of an operation comes from logic and universal algebra, where operations are used to build terms, which represent values. (To dive into the formality, see, e.g., the Term Algebra Wikipedia entry.)
An operation op has a type-signature op: [T1, T2, ..., Tn] → T, where [T1, T2, ..., Tn]
is the list of input types, and T is the output type. The input types are represented by an
ordered list of Type
objects, and the output type is a single Type
object.
For a non-static method call or an instance field access, the first input type is always the
declaring class of the method or field. If we have a method int A.m(double d)
, it is
represented as an operation m : [A, double] → int. A value, such as an int or enum constant,
can be represented as an operation with no input types, and its own type as the output type. So,
the number 5 is represented by the operation 5 : [] → int. Non-class values are represented
by NonreceiverTerm
objects.
When an Operation is used in a statement the actual inputs have to be identified. Execution of
the statement will call CallableOperation.execute(Object[])
with concrete values for each
of the inputs.
To support text-based serialization, an implementing class C should also provide:
C.parse(x.toParsableString()).equals(x)
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getName()
Returns the name for the operation.
|
java.lang.Object |
getValue()
Returns the "value" of an operation that is actually a ground term, meaning a constant of some
form.
|
boolean |
isConstantField()
Predicate to indicate whether this object represents a constant field.
|
boolean |
isConstructorCall()
Predicate to indicate whether object represents a call to a constructor.
|
boolean |
isMessage()
Predicate to indicate whether object represents a method-call-like operation (either static or
instance).
|
boolean |
isMethodCall()
Indicates whether this object represents a method-call operation (either static or instance).
|
boolean |
isNonreceivingValue()
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 |
isUncheckedCast()
Predicate to indicate whether this object represents an unchecked cast.
|
boolean |
satisfies(ReflectionPredicate reflectionPredicate)
Determines whether the reflective object in this
Operation satisfies the canUse
criteria of the given ReflectionPredicate . |
boolean isStatic()
boolean isMessage()
boolean isMethodCall()
boolean isConstructorCall()
boolean isConstantField()
boolean isNonreceivingValue()
boolean isUncheckedCast()
java.lang.Object getValue()
This is a hack to allow randoop.main.GenBranchDir to do mutation.
java.lang.IllegalArgumentException
- if no meaningful definition of "value" for typeboolean satisfies(ReflectionPredicate reflectionPredicate)
Operation
satisfies the canUse
criteria of the given ReflectionPredicate
.reflectionPredicate
- a ReflectionPredicate
to be checkedjava.lang.String getName()