public static class PropertySupport.Reflection<T> extends Node.Property<T>
FeatureDescriptor.getName()
will be set automatically.Modifier and Type | Field and Description |
---|---|
protected Object |
instance
Instance of a bean.
|
Constructor and Description |
---|
Reflection(Object instance,
Class<T> valueType,
Method getter,
Method setter)
Create a support with method objects specified.
|
Reflection(Object instance,
Class<T> valueType,
String property)
Create a support based on the property name.
|
Reflection(Object instance,
Class<T> valueType,
String getter,
String setter)
Create a support with methods specified by name.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canRead()
Test whether the property is readable.
|
boolean |
canWrite()
Test whether the property is writable.
|
PropertyEditor |
getPropertyEditor()
Get a property editor for this property.
|
T |
getValue()
Get the value.
|
void |
setPropertyEditorClass(Class<? extends PropertyEditor> clazz)
Set the property editor explicitly.
|
void |
setValue(T val)
Set the value.
|
equals, getHtmlDisplayName, getValueType, hashCode, isDefaultValue, restoreDefaultValue, supportsDefaultValue
attributeNames, getDisplayName, getName, getShortDescription, getValue, isExpert, isHidden, isPreferred, setDisplayName, setExpert, setHidden, setName, setPreferred, setShortDescription, setValue, toString
protected Object instance
public Reflection(Object instance, Class<T> valueType, Method getter, Method setter)
instance
- (Bean) object to work onvalueType
- type of the propertygetter
- getter method, can be null
setter
- setter method, can be null
IllegalArgumentException
- if the methods are not publicpublic Reflection(Object instance, Class<T> valueType, String getter, String setter) throws NoSuchMethodException
instance
- (Bean) object to work onvalueType
- type of the propertygetter
- name of getter method, can be null
setter
- name of setter method, can be null
NoSuchMethodException
- if the getter or setter methods cannot be foundpublic Reflection(Object instance, Class<T> valueType, String property) throws NoSuchMethodException
get
and
set
, respectively.instance
- object to work onvalueType
- type of the propertyproperty
- name of propertyNoSuchMethodException
- if the getter or setter methods cannot be foundpublic boolean canRead()
Node.Property
canRead
in class Node.Property<T>
true
if it ispublic T getValue() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
Node.Property
getValue
in class Node.Property<T>
IllegalAccessException
- cannot access the called methodInvocationTargetException
- an exception during invocationIllegalArgumentException
public boolean canWrite()
Node.Property
canWrite
in class Node.Property<T>
true
if the read of the value is supportedpublic void setValue(T val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
Node.Property
setValue
in class Node.Property<T>
val
- the new value of the propertyIllegalAccessException
- cannot access the called methodIllegalArgumentException
- wrong argumentInvocationTargetException
- an exception during invocationpublic PropertyEditor getPropertyEditor()
Node.Property
PropertyEditorManager
. If a property
editor is found, its instance is cached using SoftReference
.
Caching happens per thread - e.g. it is guaranteed that multiple
threads accessing the editor will get different instance.getPropertyEditor
in class Node.Property<T>
null
if there is no editorpublic void setPropertyEditorClass(Class<? extends PropertyEditor> clazz)
clazz
- class type of the property editor