Package randoop.field
Class AccessibleField
- java.lang.Object
-
- randoop.field.AccessibleField
-
public class AccessibleField extends Object
-
-
Field Summary
Fields Modifier and Type Field Description private ClassOrInterfaceType
declaringType
private Field
field
private boolean
isFinal
private boolean
isStatic
-
Constructor Summary
Constructors Constructor Description AccessibleField(Field field, ClassOrInterfaceType declaringType)
Create the public field object for the givenField
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
ClassOrInterfaceType
getDeclaringType()
String
getName()
Returns the declared name of the field.Field
getRawField()
Object
getValue(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 enclosedField
object satisfies the given predicate.void
setValue(Object object, Object value)
Uses reflection to set the value of the field for the given object.String
toCode(Type declaringType, List<Variable> inputVars)
Translates field into a string representing fully-qualified name.String
toParsableString(Type declaringType)
Returns a string descriptor of a field that can be parsed byFieldParser.parse(String, String, String)
.String
toString()
Returns string representation of underlyingField
object.
-
-
-
Field Detail
-
field
private Field field
-
declaringType
private final ClassOrInterfaceType declaringType
-
isFinal
private boolean isFinal
-
isStatic
private boolean isStatic
-
-
Constructor Detail
-
AccessibleField
public AccessibleField(Field field, ClassOrInterfaceType declaringType)
Create the public field object for the givenField
.- Parameters:
field
- the fielddeclaringType
- the type for the declaring class of this field
-
-
Method Detail
-
getName
public String getName()
Returns the declared name of the field.- Returns:
- unqualified name of the field
-
toCode
public String toCode(Type declaringType, List<Variable> inputVars)
Translates field into a string representing fully-qualified name.- Parameters:
declaringType
- the declaring type for this fieldinputVars
- list of input variables- Returns:
- string representing code representation of field
-
toParsableString
public String toParsableString(Type declaringType)
Returns a string descriptor of a field that can be parsed byFieldParser.parse(String, String, String)
.- Parameters:
declaringType
- the declaring class type for this field- Returns:
- a String for type-field pair describing field
-
getValue
public Object getValue(Object object)
Uses reflection to return the value of the field for the given object. Suppresses exceptions that occur because PublicField was not correctly initialized.- Parameters:
object
- instance to which field belongs, or null if field is static- Returns:
- reference to value of field
- Throws:
RandoopBug
- if field access throwsIllegalArgumentException
orIllegalAccessException
.
-
setValue
public void setValue(Object object, Object value)
Uses reflection to set the value of the field for the given object. Suppresses exceptions that occur because setup was incorrect.- Parameters:
object
- instance to which field belongs, or null if staticvalue
- new value to assign to field- Throws:
RandoopBug
- if field access throwsIllegalArgumentException
orIllegalAccessException
.
-
isStatic
public boolean isStatic()
isStatic returns the default that a field is not static.- Returns:
- false (default for a field)
-
isFinal
public boolean isFinal()
-
satisfies
public boolean satisfies(ReflectionPredicate reflectionPredicate)
satisfies checks whether the enclosedField
object satisfies the given predicate.- Parameters:
reflectionPredicate
- theReflectionPredicate
to check this.field against- Returns:
- true if this.field satisfies predicate.canUse(field)
-
getRawField
public Field getRawField()
-
getDeclaringType
public ClassOrInterfaceType getDeclaringType()
-
-