public static Map<String, String> getProperties(Object bean) {
        Map<String, String> properties = new HashMap<>();
        try {
            BeanInfo beanInfo = Introspector.getBeanInfo(bean.getClass());
            // Loop through all properties of the bean.
            PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
            String [] names = new String[descriptors.length];
            for (int i=0; i<names.length; i++) {
                // Determine the property name.
                String name = descriptors[i].getName();
                //Class type = descriptors[i].getPropertyType();
                // Decode the property value using the property type and
                // encoded String value.
                Object value = descriptors[i].getReadMethod().invoke(bean,(java.lang.Object[]) null);
                // Add to Map, encoding the value as a String.
                properties.put(name, encode(value));
            }
        }
        catch (Exception e) {
            Log.error(e.getMessage(), e);
        }
        return properties;
    }
Gets the properties from a Java Bean and returns them in a Map of String
name/value pairs. Because this method has to know how to convert a
bean property into a String value, only a few bean property
types are supported. They are: String, boolean, int, long, float, double,
Color, and Class.

@param bean a Java Bean to get properties from.
@return a Map of all properties as String name/value pairs.
xmppserver/src/main/java/org/jivesoftware/util/BeanUtils.java