@Test public void objectToParams() throws Exception { List<Param> params = ObjectToParam.objectToParams(new Person()); for (Param param: params) { System.out.println(param.getParamKey()+"===>"+param.getParamValue()); } }
public static List<Param> objectToParams(BaseRequestParam baseRequestParam) throws Exception { List<Param> params = new ArrayList<>(); if (baseRequestParam != null) { Class<?> objectClass = baseRequestParam.getClass(); params.addAll(getFieldParam(objectClass, baseRequestParam)); params.addAll(getMethodParam(objectClass, baseRequestParam)); Class<?> superclass = objectClass.getSuperclass(); while (!superclass.isAssignableFrom(Object.class)){ params.addAll(getFieldParam(superclass, baseRequestParam)); params.addAll(getMethodParam(superclass, baseRequestParam)); superclass = superclass.getSuperclass(); } } else { throw new NullPointerException("param object can not be null"); } return params; }
ObjectToParam { public static List<Param> objectToParams(BaseRequestParam baseRequestParam) throws Exception { List<Param> params = new ArrayList<>(); if (baseRequestParam != null) { Class<?> objectClass = baseRequestParam.getClass(); params.addAll(getFieldParam(objectClass, baseRequestParam)); params.addAll(getMethodParam(objectClass, baseRequestParam)); Class<?> superclass = objectClass.getSuperclass(); while (!superclass.isAssignableFrom(Object.class)){ params.addAll(getFieldParam(superclass, baseRequestParam)); params.addAll(getMethodParam(superclass, baseRequestParam)); superclass = superclass.getSuperclass(); } } else { throw new NullPointerException("param object can not be null"); } return params; } }
ObjectToParam { public static List<Param> objectToParams(BaseRequestParam baseRequestParam) throws Exception { List<Param> params = new ArrayList<>(); if (baseRequestParam != null) { Class<?> objectClass = baseRequestParam.getClass(); params.addAll(getFieldParam(objectClass, baseRequestParam)); params.addAll(getMethodParam(objectClass, baseRequestParam)); Class<?> superclass = objectClass.getSuperclass(); while (!superclass.isAssignableFrom(Object.class)){ params.addAll(getFieldParam(superclass, baseRequestParam)); params.addAll(getMethodParam(superclass, baseRequestParam)); superclass = superclass.getSuperclass(); } } else { throw new NullPointerException("param object can not be null"); } return params; }  }
ObjectToParam { public static List<Param> objectToParams(BaseRequestParam baseRequestParam) throws Exception { List<Param> params = new ArrayList<>(); if (baseRequestParam != null) { Class<?> objectClass = baseRequestParam.getClass(); params.addAll(getFieldParam(objectClass, baseRequestParam)); params.addAll(getMethodParam(objectClass, baseRequestParam)); Class<?> superclass = objectClass.getSuperclass(); while (!superclass.isAssignableFrom(Object.class)){ params.addAll(getFieldParam(superclass, baseRequestParam)); params.addAll(getMethodParam(superclass, baseRequestParam)); superclass = superclass.getSuperclass(); } } else { throw new NullPointerException("param object can not be null"); } return params; }  static List<Param> objectToParams(BaseRequestParam baseRequestParam); }
ObjectToParam { public static List<Param> objectToParams(BaseRequestParam baseRequestParam) throws Exception { List<Param> params = new ArrayList<>(); if (baseRequestParam != null) { Class<?> objectClass = baseRequestParam.getClass(); params.addAll(getFieldParam(objectClass, baseRequestParam)); params.addAll(getMethodParam(objectClass, baseRequestParam)); Class<?> superclass = objectClass.getSuperclass(); while (!superclass.isAssignableFrom(Object.class)){ params.addAll(getFieldParam(superclass, baseRequestParam)); params.addAll(getMethodParam(superclass, baseRequestParam)); superclass = superclass.getSuperclass(); } } else { throw new NullPointerException("param object can not be null"); } return params; }  static List<Param> objectToParams(BaseRequestParam baseRequestParam);  }