@Test public void getFiledValue() throws NoSuchFieldException { User user = new User() ; user.setId(1); user.setName("abc"); Object name = Instance.getFiledValue(user, user.getClass().getDeclaredField("name")); System.out.println(name); }
public static Object getFiledValue(Object obj, Field field){ try { Method method = obj.getClass().getDeclaredMethod("get" + methodName(field.getName())); return method.invoke(obj) ; } catch (Exception e) { log.error("Exception", e); } return null ; }
Instance { public static Object getFiledValue(Object obj, Field field){ try { Method method = obj.getClass().getDeclaredMethod("get" + methodName(field.getName())); return method.invoke(obj) ; } catch (Exception e) { log.error("Exception", e); } return null ; } }
Instance { public static Object getFiledValue(Object obj, Field field){ try { Method method = obj.getClass().getDeclaredMethod("get" + methodName(field.getName())); return method.invoke(obj) ; } catch (Exception e) { log.error("Exception", e); } return null ; }  }
Instance { public static Object getFiledValue(Object obj, Field field){ try { Method method = obj.getClass().getDeclaredMethod("get" + methodName(field.getName())); return method.invoke(obj) ; } catch (Exception e) { log.error("Exception", e); } return null ; }  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 Object getFiledValue(Object obj, Field field){ try { Method method = obj.getClass().getDeclaredMethod("get" + methodName(field.getName())); return method.invoke(obj) ; } catch (Exception e) { log.error("Exception", e); } return null ; }  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);  }