*
* @param params
* @param entity
*/
public Object populate(Object entity, String entityName, Map<String, Object> params) {
Type type = Model.getType(entityName);
for (final Map.Entry<String, Object> paramEntry : params.entrySet()) {
String attr = paramEntry.getKey();
Object value = paramEntry.getValue();
if (value instanceof String) {
if (StringUtils.isEmpty((String) value)) {
value = null;
} else if (TRIM_STR) {
value = ((String) value).trim();
}
}
// 主键
if (null != type && type.isEntityType() && attr.equals(((EntityType) type).getIdPropertyName())) {
if (ValidEntityKeyPredicate.INSTANCE.evaluate(value)) {
setValue(attr, value, entity);
} else {
try {
PropertyUtils.setProperty(entity, attr, null);