@Test public void copyListObject() { Student student1 = new Student("zhang3", 20, new Teacher("li4"), ListUtil.newArrayList("chinese", "english")); Student student2 = new Student("zhang4", 30, new Teacher("li5"), ListUtil.newArrayList("chinese2", "english4")); Student student3 = new Student("zhang5", 40, new Teacher("li6"), ListUtil.newArrayList("chinese3", "english5")); List<Student> studentList = ListUtil.newArrayList(student1, student2, student3); List<StudentVO> studentVoList = BeanMapper.mapList(studentList, StudentVO.class); assertThat(studentVoList).hasSize(3); StudentVO studentVo = studentVoList.get(0); assertThat(studentVo.name).isEqualTo("zhang3"); assertThat(studentVo.getAge()).isEqualTo(20); assertThat(studentVo.getTeacher().getName()).isEqualTo("li4"); assertThat(studentVo.getCourse()).containsExactly("chinese", "english"); }
public static <S, D> List<D> mapList(Iterable<S> sourceList, Class<D> destinationClass) { List<D> destionationList = new ArrayList<D>(); for (S source : sourceList) { if (source != null) { destionationList.add(mapper.map(source, destinationClass)); } } return destionationList; }
BeanMapper { public static <S, D> List<D> mapList(Iterable<S> sourceList, Class<D> destinationClass) { List<D> destionationList = new ArrayList<D>(); for (S source : sourceList) { if (source != null) { destionationList.add(mapper.map(source, destinationClass)); } } return destionationList; } }
BeanMapper { public static <S, D> List<D> mapList(Iterable<S> sourceList, Class<D> destinationClass) { List<D> destionationList = new ArrayList<D>(); for (S source : sourceList) { if (source != null) { destionationList.add(mapper.map(source, destinationClass)); } } return destionationList; }  }
BeanMapper { public static <S, D> List<D> mapList(Iterable<S> sourceList, Class<D> destinationClass) { List<D> destionationList = new ArrayList<D>(); for (S source : sourceList) { if (source != null) { destionationList.add(mapper.map(source, destinationClass)); } } return destionationList; }  static D map(S source, Class<D> destinationClass); static List<D> mapList(Iterable<S> sourceList, Class<D> destinationClass); static D[] mapArray(final S[] sourceArray, final Class<D> destinationClass); }
BeanMapper { public static <S, D> List<D> mapList(Iterable<S> sourceList, Class<D> destinationClass) { List<D> destionationList = new ArrayList<D>(); for (S source : sourceList) { if (source != null) { destionationList.add(mapper.map(source, destinationClass)); } } return destionationList; }  static D map(S source, Class<D> destinationClass); static List<D> mapList(Iterable<S> sourceList, Class<D> destinationClass); static D[] mapArray(final S[] sourceArray, final Class<D> destinationClass);  }