ExcelFieldService { public static Iterator<Field> getFields(final Class clazz) { final Iterator<Field> fields; if (fieldsCache.get(clazz) != null) { final List<Field> fieldsList = fieldsCache.get(clazz); fields = fieldsList.iterator(); } else { final ClassFields classFields = new ClassFieldsExcelExport(new ClassFieldsDefault(clazz, true)); fields = classFields.getFields(); fieldsCache.put(clazz, Lists.newArrayList(classFields.getFields())); } return fields; } private  ExcelFieldService(); static FieldType getFieldType(final Field field); static Class getFieldClass(final Field field); static Iterator<Field> getFields(final Class clazz); static Long getObjectID(final Object object); static String getFieldName(final Class clazz, final Field field, final TranslateService translateService); static Class[] getFieldClazz(final Field field); static Boolean isCollection(final Field field);  }
@Test public void getFields() throws Exception { final String[] expectedFields = {"otherClass1", "otherClass2"}; final Iterator<Field> fields = ExcelFieldService.getFields(TestClass.class); final List<String> actualFields = new ArrayList<>(); while (fields.hasNext()) { final Field f = fields.next(); actualFields.add(f.getName()); } Assert.assertArrayEquals("Check get fields", expectedFields, actualFields.toArray()); }