public class PropertyInfo extends AccessibleObject implements Member
It consist of a getter and/or setter Method
and can be easily created by TypeExtensions.getProperty(Class, String, BindingFlags)
.
Constructor and Description |
---|
PropertyInfo(String name,
int modifiers,
Class<?> declaringType,
Method getter,
Method setter)
Creates a initializes a new instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
<T extends Annotation> |
getAnnotation(Class<T> annotationClass) |
<T extends Annotation> |
getAnnotationsByType(Class<T> annotationClass) |
Annotation[] |
getDeclaredAnnotations() |
Class<?> |
getDeclaringClass() |
Method |
getGetter()
Returns the getter method of this property.
|
int |
getModifiers() |
String |
getName() |
Method |
getSetter()
Returns the setter method of this property.
|
Type |
getType()
Returns the type of the property.
|
Object |
getValue(Object instance)
|
int |
hashCode() |
boolean |
isReadable()
Returns whether this property has a getter and is therefore readable.
|
boolean |
isSynthetic() |
boolean |
isWriteable()
Returns whether this property has a setter and is therefore writeable.
|
void |
setValue(Object instance,
Object value)
|
getAnnotations, getDeclaredAnnotation, getDeclaredAnnotationsByType, isAccessible, isAnnotationPresent, setAccessible, setAccessible
public PropertyInfo(String name, int modifiers, Class<?> declaringType, Method getter, Method setter)
name
- The simple name of the property.modifiers
- The modifiers as defined in Modifier
.declaringType
- The type declaring this property.getter
- The getter method.setter
- The setter method.public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
getAnnotation
in interface AnnotatedElement
getAnnotation
in class AccessibleObject
public <T extends Annotation> T[] getAnnotationsByType(Class<T> annotationClass)
getAnnotationsByType
in interface AnnotatedElement
getAnnotationsByType
in class AccessibleObject
public Annotation[] getDeclaredAnnotations()
getDeclaredAnnotations
in interface AnnotatedElement
getDeclaredAnnotations
in class AccessibleObject
public Class<?> getDeclaringClass()
getDeclaringClass
in interface Member
public Method getGetter()
public int getModifiers()
getModifiers
in interface Member
public Method getSetter()
public Type getType()
If there is a Getter
, its generic return type
is used.
Otherwise the parameterized type
of the first parameter of the Setter
is returned.
public Object getValue(Object instance) throws InvocationTargetException, IllegalAccessException
InvocationTargetException
- If the underlying method throws an exception.IllegalAccessException
- If the underlying method is inaccessible.instance
- The instance to get the value from.public boolean isReadable()
public boolean isSynthetic()
isSynthetic
in interface Member
public boolean isWriteable()
public void setValue(Object instance, Object value) throws InvocationTargetException, IllegalAccessException
InvocationTargetException
- If the underlying method throws an exception.IllegalAccessException
- If the underlying method is inaccessible.instance
- The instance to set the value on.value
- The value to set.