/** * Get Map of property values from a bean. * * @param obj Object to query for properties. * @param allowedProperties If array is NOT null, only the properties matching names * passed here shall be retrieved. * @return Map containing property-name (String) / property-value (Object) pairs. */ public final static Map getValues(Object obj, String[] allowedProperties) { Map result = new HashMap(); String[] propertyNames = getPropertyNames(obj); for (int i = 0; i < propertyNames.length; i++) { String propertyName = propertyNames[i]; Object propertyValue = getValue(obj, propertyName); if ((propertyName == null) || (propertyValue == null)) { continue; } if (allowed(propertyName, allowedProperties)) { result.put(propertyName, propertyValue); } } return result; }
/** * Get Map of property values from a bean. * * @param obj Object to query for properties. * @param allowedProperties If array is NOT null, only the properties matching names * passed here shall be retrieved. * @return Map containing property-name (String) / property-value (Object) pairs. */ public final static Map getValues(Object obj, String[] allowedProperties) { Map result = new HashMap(); String[] propertyNames = getPropertyNames(obj); for (int i = 0; i < propertyNames.length; i++) { String propertyName = propertyNames[i]; Object propertyValue = getValue(obj, propertyName); if ((propertyName == null) || (propertyValue == null)) { continue; } if (allowed(propertyName, allowedProperties)) { result.put(propertyName, propertyValue); } } return result; }