public class InstanceField
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.lang.reflect.Field |
field |
private FieldReader |
fieldReader |
private java.lang.Object |
instance |
Constructor and Description |
---|
InstanceField(java.lang.reflect.Field field,
java.lang.Object instance)
Create a new InstanceField.
|
Modifier and Type | Method and Description |
---|---|
<A extends java.lang.annotation.Annotation> |
annotation(java.lang.Class<A> annotationClass)
Returns the annotation instance for the given annotation type.
|
boolean |
equals(java.lang.Object o) |
int |
hashCode() |
boolean |
isAnnotatedBy(java.lang.Class<? extends java.lang.annotation.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.
|
java.lang.reflect.Field |
jdkField()
Returns the JDK
Field instance. |
java.lang.String |
name()
Returns the name of the field.
|
java.lang.Object |
read()
Safely read the field.
|
private FieldReader |
reader() |
void |
set(java.lang.Object value)
Set the given value to the field of this instance.
|
java.lang.String |
toString() |
private final java.lang.reflect.Field field
private final java.lang.Object instance
private FieldReader fieldReader
public InstanceField(java.lang.reflect.Field field, java.lang.Object instance)
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.public java.lang.Object read()
FieldReader
public void set(java.lang.Object value)
value
- The value that should be written to the field.FieldSetter
public boolean isNull()
true
if null
, else false
.public boolean isAnnotatedBy(java.lang.Class<? extends java.lang.annotation.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 java.lang.annotation.Annotation> A annotation(java.lang.Class<A> annotationClass)
A
- Type of the annotation.annotationClass
- Tha annotation type to retrieve.public java.lang.reflect.Field jdkField()
Field
instance.Field
instance.private FieldReader reader()
public java.lang.String name()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object