Esempio n. 1
0
  public static List<UserBookDto> changeToDto(User user, List<Book> books) {

    List<UserBookDto> dto = new ArrayList<UserBookDto>();
    for (Book book : books) {
      UserBookDto d = new UserBookDto();
      d.setUsername(user.getUsername());
      d.setIsreturn("N");
      d.setBookname(book.getBookname());
      dto.add(d);
    }
    return dto;
  }
Esempio n. 2
0
 public static Object[][] changeToArray(List<UserBookDto> dto, String[] attributes) {
   Object[][] result = new Object[dto.size()][attributes.length];
   for (int i = 0; i < dto.size(); i++) {
     UserBookDto b = dto.get(i);
     for (int j = 0; j < attributes.length; j++) {
       try {
         result[i][j] =
             b.getClass().getMethod(createGetMethod(attributes[j]), null).invoke(b, null);
       } catch (IllegalAccessException
           | IllegalArgumentException
           | InvocationTargetException
           | NoSuchMethodException
           | SecurityException e) {
         e.printStackTrace();
       }
     }
   }
   return result;
 }