private static void collectFields(final Class clazz, final ArrayList<Field> result) {
   final Field[] fields = clazz.getDeclaredFields();
   result.addAll(Arrays.asList(fields));
   final Class superClass = clazz.getSuperclass();
   if (superClass != null) {
     collectFields(superClass, result);
   }
   final Class[] interfaces = clazz.getInterfaces();
   for (Class each : interfaces) {
     collectFields(each, result);
   }
 }
 public static ArrayList<Field> collectFields(Class clazz) {
   ArrayList<Field> result = new ArrayList<Field>();
   collectFields(clazz, result);
   return result;
 }