private static PropertyDescriptor [ ] [ ] getBeanProperties ( Class < ? > beanType ) { List < PropertyDescriptor > readProperties = new ArrayList < PropertyDescriptor > ( ) ; List < PropertyDescriptor > writeProperties = new ArrayList < PropertyDescriptor > ( ) ; try { Map < ? , ? > map = CompleteIntrospector . getAllProperties ( beanType ) ; Iterator < ? > it = map . values ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { PropertyDescriptor pd = ( PropertyDescriptor ) it . next ( ) ; if ( pd . getReadMethod ( ) != null ) { readProperties . add ( pd ) ; } if ( pd . getWriteMethod ( ) != null ) { writeProperties . add ( pd ) ; } } } catch ( IntrospectionException e ) { throw new RuntimeException ( e . toString ( ) ) ; } PropertyDescriptor [ ] [ ] props = new PropertyDescriptor [ 2 ] [ ] ; props [ 0 ] = new PropertyDescriptor [ readProperties . size ( ) ] ; readProperties . toArray ( props [ 0 ] ) ; props [ 1 ] = new PropertyDescriptor [ writeProperties . size ( ) ] ; writeProperties . toArray ( props [ 1 ] ) ; return props ; }
Returns two arrays of PropertyDescriptors . Array 0 has contains read PropertyDescriptors array 1 contains the write PropertyDescriptors .