Skip to content

Commit

Permalink
Merge pull request thinkgem#282 from QinChery/patch-3
Browse files Browse the repository at this point in the history
Update ObjectUtils.java
  • Loading branch information
think-gem authored Dec 31, 2016
2 parents 8fcdf70 + 94f0602 commit a9f1524
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ public class ObjectUtils extends org.apache.commons.lang3.ObjectUtils {
public static void annotationToObject(Object annotation, Object object){
if (annotation != null){
Class<?> annotationClass = annotation.getClass();
if (null == object) {
return;
}
Class<?> objectClass = object.getClass();
for (Method m : objectClass.getMethods()){
if (StringUtils.startsWith(m.getName(), "set")){
try {
String s = StringUtils.uncapitalize(StringUtils.substring(m.getName(), 3));
Object obj = annotationClass.getMethod(s).invoke(annotation);
if (obj != null && !"".equals(obj.toString())){
if (object == null){
object = objectClass.newInstance();
}
m.invoke(object, obj);
}
} catch (Exception e) {
Expand Down

0 comments on commit a9f1524

Please sign in to comment.