public class AccessibleField
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private ClassOrInterfaceType |
declaringType |
private java.lang.reflect.Field |
field |
private boolean |
isFinal |
private boolean |
isStatic |
Constructor and Description |
---|
AccessibleField(java.lang.reflect.Field field,
ClassOrInterfaceType declaringType)
Create the public field object for the given
Field . |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(@Nullable java.lang.Object obj) |
ClassOrInterfaceType |
getDeclaringType() |
java.lang.String |
getName()
Returns the declared name of the field.
|
java.lang.reflect.Field |
getRawField() |
java.lang.Object |
getValue(java.lang.Object object)
Uses reflection to return the value of the field for the given object.
|
int |
hashCode() |
boolean |
isFinal() |
boolean |
isStatic()
isStatic returns the default that a field is not static.
|
boolean |
satisfies(ReflectionPredicate reflectionPredicate)
satisfies checks whether the enclosed
Field object satisfies the given predicate. |
void |
setValue(java.lang.Object object,
java.lang.Object value)
Uses reflection to set the value of the field for the given object.
|
java.lang.String |
toCode(Type declaringType,
java.util.List<Variable> inputVars)
Translates field into a string representing fully-qualified name.
|
java.lang.String |
toParsableString(Type declaringType)
Returns a string descriptor of a field that can be parsed by
FieldParser.parse(String,
String, String) . |
java.lang.String |
toString()
Returns string representation of underlying
Field object. |
private java.lang.reflect.Field field
private final ClassOrInterfaceType declaringType
private boolean isFinal
private boolean isStatic
public AccessibleField(java.lang.reflect.Field field, ClassOrInterfaceType declaringType)
Field
.field
- the fielddeclaringType
- the type for the declaring class of this fieldpublic java.lang.String getName()
public java.lang.String toCode(Type declaringType, java.util.List<Variable> inputVars)
declaringType
- the declaring type for this fieldinputVars
- list of input variablespublic java.lang.String toParsableString(Type declaringType)
FieldParser.parse(String,
String, String)
.declaringType
- the declaring class type for this fieldpublic java.lang.String toString()
Field
object.toString
in class java.lang.Object
public boolean equals(@Nullable java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.Object getValue(java.lang.Object object)
object
- instance to which field belongs, or null if field is staticRandoopBug
- if field access throws IllegalArgumentException
or IllegalAccessException
.public void setValue(java.lang.Object object, java.lang.Object value)
object
- instance to which field belongs, or null if staticvalue
- new value to assign to fieldRandoopBug
- if field access throws IllegalArgumentException
or IllegalAccessException
.public boolean isStatic()
public boolean isFinal()
public boolean satisfies(ReflectionPredicate reflectionPredicate)
Field
object satisfies the given predicate.reflectionPredicate
- the ReflectionPredicate
to check this.field againstpublic java.lang.reflect.Field getRawField()
public ClassOrInterfaceType getDeclaringType()