Example #1
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;
 }