@Test public void transfer() { User user = Instance.transfer(User.class, "id", 123); log.info("user={}", user.toString()); }
public static <T extends Model> T transfer(Class<T> target, String filedName, Object value) { if (filedName == null || value == null){ throw new RuntimeException("argument is null!") ; } T obj = null; try { obj = target.newInstance(); filedName = methodName(filedName) ; Method method = target.getMethod("set" + filedName ,value.getClass()); method.invoke(obj, value); return obj; } catch (Exception e) { log.error("exception",e); } return obj; }
Instance { public static <T extends Model> T transfer(Class<T> target, String filedName, Object value) { if (filedName == null || value == null){ throw new RuntimeException("argument is null!") ; } T obj = null; try { obj = target.newInstance(); filedName = methodName(filedName) ; Method method = target.getMethod("set" + filedName ,value.getClass()); method.invoke(obj, value); return obj; } catch (Exception e) { log.error("exception",e); } return obj; } }
Instance { public static <T extends Model> T transfer(Class<T> target, String filedName, Object value) { if (filedName == null || value == null){ throw new RuntimeException("argument is null!") ; } T obj = null; try { obj = target.newInstance(); filedName = methodName(filedName) ; Method method = target.getMethod("set" + filedName ,value.getClass()); method.invoke(obj, value); return obj; } catch (Exception e) { log.error("exception",e); } return obj; }  }
Instance { public static <T extends Model> T transfer(Class<T> target, String filedName, Object value) { if (filedName == null || value == null){ throw new RuntimeException("argument is null!") ; } T obj = null; try { obj = target.newInstance(); filedName = methodName(filedName) ; Method method = target.getMethod("set" + filedName ,value.getClass()); method.invoke(obj, value); return obj; } catch (Exception e) { log.error("exception",e); } return obj; }  static T transfer(Class<T> target, String filedName, Object value); static T transfer(Class<T> target, Map<String,Object> params); static Object getFiledValue(Object obj, Field field); }
Instance { public static <T extends Model> T transfer(Class<T> target, String filedName, Object value) { if (filedName == null || value == null){ throw new RuntimeException("argument is null!") ; } T obj = null; try { obj = target.newInstance(); filedName = methodName(filedName) ; Method method = target.getMethod("set" + filedName ,value.getClass()); method.invoke(obj, value); return obj; } catch (Exception e) { log.error("exception",e); } return obj; }  static T transfer(Class<T> target, String filedName, Object value); static T transfer(Class<T> target, Map<String,Object> params); static Object getFiledValue(Object obj, Field field);  }