public static Map < String , Object > read ( Object object ) { PropertyDescriptor [ ] descriptors ; Class < ? > clazz = object . getClass ( ) ; try { descriptors = getPropertyDescriptors ( clazz ) ; } catch ( IntrospectionException e ) { LOG . error ( "Failed to introspect " + clazz , e ) ; return Collections . emptyMap ( ) ; } HashMap < String , Object > map = new HashMap <> ( descriptors . length ) ; for ( PropertyDescriptor pd : descriptors ) { try { Object value = pd . getReadMethod ( ) . invoke ( object ) ; map . put ( pd . getName ( ) , value ) ; } catch ( IllegalAccessException | InvocationTargetException | IllegalArgumentException e ) { LOG . error ( "Failed to visit property " + pd . getName ( ) , e ) ; } } map . remove ( "class" ) ; return map ; }
Returns a create of all property names and their values contained in the given object .