/** * Goes recursively into the interface and gets all defined * propertyDescriptors * * @param propertyDescriptors * The result list of all PropertyDescriptors the given interface * defines (hierarchical) * @param iface * The interface to fetch the PropertyDescriptors * @throws IntrospectionException */ private static void getInterfacePropertyDescriptors( List<PropertyDescriptor> propertyDescriptors, Class<?> iface) throws IntrospectionException { BeanInfo beanInfo = Introspector.getBeanInfo(iface); PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors(); for (int i = 0; i < pds.length; i++) { PropertyDescriptor pd = pds[i]; propertyDescriptors.add(pd); } Class<?>[] subIntfs = iface.getInterfaces(); for (int j = 0; j < subIntfs.length; j++) { getInterfacePropertyDescriptors(propertyDescriptors, subIntfs[j]); } }
PropertyDescriptor propertyDescriptors[]; List<PropertyDescriptor> pds = new ArrayList<>(); getInterfacePropertyDescriptors(pds, beanClass); if (pds.size() > 0) { propertyDescriptors = (PropertyDescriptor[]) pds