实现方法:
public static <T> T transform(Object a, Class<T> b, String[] as, String[] bs) {
T t = null;
try {
t = b.newInstance();
Field[] fields = a.getClass().getDeclaredFields();
A:
for (Field field : fields) {
if (!field.isAccessible()) {
field.setAccessible(true);
}
for (int i = 0; i < as.length; i++) {
if (as[i].equals(field.getName())) {
Field[] tfields = t.getClass().getDeclaredFields();
for (Field tfield : tfields) {
if (!tfield.isAccessible()) {
tfield.setAccessible(true);
}
if (bs[i].equals(tfield.getName())) {
tfield.set(t, field.get(a));