Class InstanceField
java.lang.Object
org.mockito.internal.util.reflection.InstanceField
Represents an accessible instance field.
Contains the instance reference on which the field can be read and write.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<A extends Annotation>
Aannotation
(Class<A> annotationClass) Returns the annotation instance for the given annotation type.boolean
int
hashCode()
boolean
isAnnotatedBy
(Class<? extends Annotation> annotationClass) Check if the field is annotated by the given annotation.boolean
isNull()
Check that the field is not null.boolean
Check if the field is synthetic.jdkField()
Returns the JDKField
instance.name()
Returns the name of the field.read()
Safely read the field.private FieldReader
reader()
void
Set the given value to the field of this instance.toString()
-
Field Details
-
field
-
instance
-
fieldReader
-
-
Constructor Details
-
InstanceField
Create a new InstanceField.- Parameters:
field
- The field that should be accessed, note that no checks are performed to ensure the field belong to this instance class.instance
- The instance from which the field shall be accessed.
-
-
Method Details
-
read
Safely read the field.- Returns:
- the field value.
- See Also:
-
set
Set the given value to the field of this instance.- Parameters:
value
- The value that should be written to the field.
-
isNull
public boolean isNull()Check that the field is not null.- Returns:
true
ifnull
, elsefalse
.
-
isAnnotatedBy
Check if the field is annotated by the given annotation.- Parameters:
annotationClass
- The annotation type to check.- Returns:
true
if the field is annotated by this annotation, elsefalse
.
-
isSynthetic
public boolean isSynthetic()Check if the field is synthetic.- Returns:
true
if the field is synthetic, elsefalse
.
-
annotation
Returns the annotation instance for the given annotation type.- Type Parameters:
A
- Type of the annotation.- Parameters:
annotationClass
- Tha annotation type to retrieve.- Returns:
- The annotation instance.
-
jdkField
Returns the JDKField
instance.- Returns:
- The actual
Field
instance.
-
reader
-
name
Returns the name of the field.- Returns:
- Name of the field.
-
toString
-
equals
-
hashCode
public int hashCode()
-