org.mockito.internal.util.reflection
public class InstanceField extends Object
Constructor and Description |
---|
InstanceField(Field field,
Object instance)
Create a new InstanceField.
|
Modifier and Type | Method and Description |
---|---|
<A extends Annotation> |
annotation(Class<A> annotationClass)
Returns the annotation instance for the given annotation type.
|
boolean |
equals(Object o) |
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 |
isSynthetic()
Check if the field is synthetic.
|
Field |
jdkField()
Returns the JDK
Field instance. |
String |
name()
Returns the name of the field.
|
Object |
read()
Safely read the field.
|
void |
set(Object value)
Set the given value to the field of this instance.
|
String |
toString() |
public Object read()
FieldReader
public void set(Object value)
value
- The value that should be written to the field.FieldSetter
public boolean isNull()
true
if null
, else false
.public boolean isAnnotatedBy(Class<? extends Annotation> annotationClass)
annotationClass
- The annotation type to check.true
if the field is annotated by this annotation, else false
.public boolean isSynthetic()
true
if the field is synthetic, else false
.public <A extends Annotation> A annotation(Class<A> annotationClass)
A
- Type of the annotation.annotationClass
- Tha annotation type to retrieve.public String name()