public class FieldGet extends CallableOperation
Operation
from a AccessibleField
and
behaves like a getter for the field.AccessibleField
Modifier and Type | Field and Description |
---|---|
private AccessibleField |
field |
Constructor and Description |
---|
FieldGet(AccessibleField field)
FieldGetter sets the public field for the getter statement.
|
Modifier and Type | Method and Description |
---|---|
void |
appendCode(Type declaringType,
TypeTuple inputTypes,
Type outputType,
java.util.List<Variable> inputVars,
java.lang.StringBuilder b)
Adds the text for an initialization of a variable from a field to the StringBuilder.
|
boolean |
equals(@Nullable java.lang.Object obj) |
ExecutionOutcome |
execute(java.lang.Object[] statementInput)
Performs computation of getting value of field or capturing thrown exceptions.
|
java.lang.String |
getName()
Returns the name for the operation.
|
int |
hashCode() |
boolean |
isConstantField()
Predicate to indicate whether this object represents a constant field.
|
boolean |
isMessage()
Predicate to indicate whether object represents a method-call-like operation (either static or
instance).
|
boolean |
isStatic()
Predicate to indicate whether object represents a static operation on the declaring class.
|
static TypedOperation |
parse(java.lang.String descr)
Parses a getter for a field from a string.
|
boolean |
satisfies(ReflectionPredicate reflectionPredicate)
Determines whether enclosed
Field satisfies the given predicate. |
java.lang.String |
toParsableString(Type declaringType,
TypeTuple inputTypes,
Type outputType)
Returns string descriptor for field that can be parsed by PublicFieldParser.
|
java.lang.String |
toString() |
getArgumentString, getReflectionObject, getValue, isConstructorCall, isMethodCall, isNonreceivingValue, isUncheckedCast
private AccessibleField field
public FieldGet(AccessibleField field)
field
- the AccessibleField
object from which to get valuespublic ExecutionOutcome execute(java.lang.Object[] statementInput)
AccessibleField.getValue(Object)
suppresses exceptions that occur because field
is not valid or accessible.execute
in class CallableOperation
statementInput
- the inputs for statementRandoopBug
- if field access throws bug exceptionSequenceExecutionException
- if field access has a type exceptionpublic void appendCode(Type declaringType, TypeTuple inputTypes, Type outputType, java.util.List<Variable> inputVars, java.lang.StringBuilder b)
appendCode
in class CallableOperation
inputVars
- the list of variables to be usedb
- the StringBuilder that strings are appended todeclaringType
- 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 CallableOperation
declaringType
- the declaring type for this operationinputTypes
- the input types for this operationoutputType
- the output type for this operationpublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getName()
Operation
public boolean equals(@Nullable java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public static TypedOperation parse(java.lang.String descr) throws OperationParseException
<get>(
field-descriptor )
" where "<get>
" is literal ("<
" and ">
" included),
and field-descriptor is as recognized bydescr
- the string containing descriptor of getter for a fieldOperationParseException
- if any error in descriptor stringpublic boolean isStatic()
Operation
isStatic
in interface Operation
isStatic
in class CallableOperation
public boolean isConstantField()
Operation
isConstantField
in interface Operation
isConstantField
in class CallableOperation
public boolean isMessage()
isMessage
in interface Operation
isMessage
in class CallableOperation
public boolean satisfies(ReflectionPredicate reflectionPredicate)
Field
satisfies the given predicate.satisfies
in interface Operation
satisfies
in class CallableOperation
reflectionPredicate
- the ReflectionPredicate
to be checked