Package randoop.field

Class AccessibleField


  • public class AccessibleField
    extends Object
    AccessibleField represents an accessible field of a class object, which can be an instance field, a static field, or a static final field. Meant to be adapted by either FieldSet or FieldGet for use as a Operation.
    • Field Detail

      • field

        private Field field
      • isFinal

        private boolean isFinal
      • isStatic

        private boolean isStatic
    • Constructor Detail

      • AccessibleField

        public AccessibleField​(Field field,
                               ClassOrInterfaceType declaringType)
        Create the public field object for the given Field.
        Parameters:
        field - the field
        declaringType - 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 field
        inputVars - 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 by FieldParser.parse(String, String, String).
        Parameters:
        declaringType - the declaring class type for this field
        Returns:
        a String for type-field pair describing field
      • toString

        public String toString()
        Returns string representation of underlying Field object.
        Overrides:
        toString in class Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • 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 throws IllegalArgumentException or IllegalAccessException.
      • 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 static
        value - new value to assign to field
        Throws:
        RandoopBug - if field access throws IllegalArgumentException or IllegalAccessException.
      • 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 enclosed Field object satisfies the given predicate.
        Parameters:
        reflectionPredicate - the ReflectionPredicate to check this.field against
        Returns:
        true if this.field satisfies predicate.canUse(field)
      • getRawField

        public Field getRawField()