class ExtendedBeanInfo
extends java.lang.Object
implements java.beans.BeanInfo
BeanInfo
object, e.g. as created by
Introspector.getBeanInfo(Class)
, designed to discover and register static
and/or non-void returning setter methods. For example:
public class Bean { private Foo foo; public Foo getFoo() { return this.foo; } public Bean setFoo(Foo foo) { this.foo = foo; return this; } }The standard JavaBeans
Introspector
will discover the getFoo
read
method, but will bypass the #setFoo(Foo)
write method, because its non-void
returning signature does not comply with the JavaBeans specification.
ExtendedBeanInfo
, on the other hand, will recognize and include it. This is
designed to allow APIs with "builder" or method-chaining style setter signatures to be
used within Spring <beans>
XML. getPropertyDescriptors()
returns all
existing property descriptors from the wrapped BeanInfo
as well any added for
non-void returning setters. Both standard ("non-indexed") and
indexed properties are fully supported.ExtendedBeanInfo(BeanInfo)
,
ExtendedBeanInfoFactory
,
CachedIntrospectionResults
Modifier and Type | Field and Description |
---|---|
private java.beans.BeanInfo |
delegate |
private java.util.Set<java.beans.PropertyDescriptor> |
propertyDescriptors |
Constructor and Description |
---|
ExtendedBeanInfo(java.beans.BeanInfo delegate)
Wrap the given
BeanInfo instance; copy all its existing property descriptors
locally, wrapping each in a custom indexed
or non-indexed PropertyDescriptor
variant that bypasses default JDK weak/soft reference management; then search
through its method descriptors to find any non-void returning write methods and
update or create the corresponding PropertyDescriptor for each one found. |
Modifier and Type | Method and Description |
---|---|
private java.util.List<java.lang.reflect.Method> |
findCandidateWriteMethods(java.beans.MethodDescriptor[] methodDescriptors) |
private java.beans.PropertyDescriptor |
findExistingPropertyDescriptor(java.lang.String propertyName,
java.lang.Class<?> propertyType) |
java.beans.BeanInfo[] |
getAdditionalBeanInfo() |
java.beans.BeanDescriptor |
getBeanDescriptor() |
int |
getDefaultEventIndex() |
int |
getDefaultPropertyIndex() |
java.beans.EventSetDescriptor[] |
getEventSetDescriptors() |
java.awt.Image |
getIcon(int iconKind) |
java.beans.MethodDescriptor[] |
getMethodDescriptors() |
java.beans.PropertyDescriptor[] |
getPropertyDescriptors()
Return the set of
PropertyDescriptor s from the wrapped BeanInfo
object as well as PropertyDescriptor s for each non-void returning setter
method found during construction. |
private void |
handleCandidateWriteMethod(java.lang.reflect.Method method) |
static boolean |
isCandidateWriteMethod(java.lang.reflect.Method method) |
private java.lang.String |
propertyNameFor(java.lang.reflect.Method method) |
private final java.beans.BeanInfo delegate
private final java.util.Set<java.beans.PropertyDescriptor> propertyDescriptors
public ExtendedBeanInfo(java.beans.BeanInfo delegate) throws java.beans.IntrospectionException
BeanInfo
instance; copy all its existing property descriptors
locally, wrapping each in a custom indexed
or non-indexed
PropertyDescriptor
variant that bypasses default JDK weak/soft reference management; then search
through its method descriptors to find any non-void returning write methods and
update or create the corresponding PropertyDescriptor
for each one found.delegate
- the wrapped BeanInfo
, which is never modifiedjava.beans.IntrospectionException
- if any problems occur creating and adding new
property descriptorsgetPropertyDescriptors()
private java.util.List<java.lang.reflect.Method> findCandidateWriteMethods(java.beans.MethodDescriptor[] methodDescriptors)
public static boolean isCandidateWriteMethod(java.lang.reflect.Method method)
private void handleCandidateWriteMethod(java.lang.reflect.Method method) throws java.beans.IntrospectionException
java.beans.IntrospectionException
private java.beans.PropertyDescriptor findExistingPropertyDescriptor(java.lang.String propertyName, java.lang.Class<?> propertyType)
private java.lang.String propertyNameFor(java.lang.reflect.Method method)
public java.beans.PropertyDescriptor[] getPropertyDescriptors()
PropertyDescriptor
s from the wrapped BeanInfo
object as well as PropertyDescriptor
s for each non-void returning setter
method found during construction.getPropertyDescriptors
in interface java.beans.BeanInfo
ExtendedBeanInfo(BeanInfo)
public java.beans.BeanInfo[] getAdditionalBeanInfo()
getAdditionalBeanInfo
in interface java.beans.BeanInfo
public java.beans.BeanDescriptor getBeanDescriptor()
getBeanDescriptor
in interface java.beans.BeanInfo
public int getDefaultEventIndex()
getDefaultEventIndex
in interface java.beans.BeanInfo
public int getDefaultPropertyIndex()
getDefaultPropertyIndex
in interface java.beans.BeanInfo
public java.beans.EventSetDescriptor[] getEventSetDescriptors()
getEventSetDescriptors
in interface java.beans.BeanInfo
public java.awt.Image getIcon(int iconKind)
getIcon
in interface java.beans.BeanInfo
public java.beans.MethodDescriptor[] getMethodDescriptors()
getMethodDescriptors
in interface java.beans.BeanInfo