public class FieldSet extends CallableOperation
AccessibleField as a Operation that acts like a
setter for the field.AccessibleField| Modifier and Type | Field and Description |
|---|---|
private AccessibleField |
field |
| Constructor and Description |
|---|
FieldSet(AccessibleField field)
Creates a setter
Operation object for a field of a class. |
| Modifier and Type | Method and Description |
|---|---|
void |
appendCode(Type declaringType,
TypeTuple inputTypes,
Type outputType,
java.util.List<Variable> inputVars,
java.lang.StringBuilder b)
Generates code for setting a field.
|
boolean |
equals(@Nullable java.lang.Object obj) |
ExecutionOutcome |
execute(java.lang.Object[] statementInput)
Sets the value of the field given the inputs.
|
java.lang.String |
getName()
Returns the name for the operation.
|
int |
hashCode() |
boolean |
isMessage()
A FieldSetter is a method call because it acts like a setter.
|
boolean |
isStatic()
Predicate to indicate whether object represents a static operation on the declaring class.
|
static TypedOperation |
parse(java.lang.String descr)
Parses a description of a field setter in the given string.
|
boolean |
satisfies(ReflectionPredicate reflectionPredicate)
Determines whether enclosed
Field satisfies the given
predicate. |
java.lang.String |
toParsableString(Type declaringType,
TypeTuple inputTypes,
Type outputType)
Returns the string descriptor for field that can be parsed by.
|
java.lang.String |
toString() |
getArgumentString, getReflectionObject, getValue, isConstantField, isConstructorCall, isMethodCall, isNonreceivingValue, isUncheckedCastprivate AccessibleField field
public FieldSet(AccessibleField field)
Operation object for a field of a class. Throws an exception if the
field is static final.field - the field object to be set by setter statementsjava.lang.IllegalArgumentException - if field is static finalpublic ExecutionOutcome execute(java.lang.Object[] statementInput)
ExecutionOutcome. Exceptions should only be NullPointerException, which happens when input is null but field is an instance field. AccessibleField.getValue(Object) suppresses exceptions that occur because the field is not
valid or accessible (specifically IllegalArgumentException and IllegalAccessException).execute in class CallableOperationstatementInput - the inputs for statementRandoopBug - if field access throws bug exceptionSequenceExecutionException - if field access has type exceptionpublic void appendCode(Type declaringType, TypeTuple inputTypes, Type outputType, java.util.List<Variable> inputVars, java.lang.StringBuilder b)
field = value;or
field = variable;
appendCode in class CallableOperationinputVars - the list of input variables. Last element is value to assign. If an instance
field, first is instance, second is value.b - the StringBuilder to which code is issueddeclaringType - the declaring type for this operationinputTypes - the input types for this operationoutputType - the output type for this operationpublic java.lang.String toParsableString(Type declaringType, TypeTuple inputTypes, Type outputType)
toParsableString in class CallableOperationdeclaringType - the declaring type for this operationinputTypes - the input types for this operationoutputType - the output type for this operationpublic static TypedOperation parse(java.lang.String descr) throws OperationParseException
<set>( field-descriptor )" where "<set>" is literally what is expected.descr - string containing descriptor of field setterOperationParseException - if descr does not have expected formpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getName()
Operationpublic boolean equals(@Nullable java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean isStatic()
OperationisStatic in interface OperationisStatic in class CallableOperationpublic boolean isMessage()
isMessage in interface OperationisMessage in class CallableOperationpublic boolean satisfies(ReflectionPredicate reflectionPredicate)
Field satisfies the given
predicate.satisfies in interface Operationsatisfies in class CallableOperationreflectionPredicate - the ReflectionPredicate to be checked