ExcelFieldService { public static FieldType getFieldType(final Field field) { FieldType fieldType; if (fieldsTypeCache.get(field) != null) { fieldType = fieldsTypeCache.get(field); } else { fieldType = FieldType.basic; final Class fieldClass = getFieldClass(field); if (FieldType.BASICTYPES.contains(fieldClass) || fieldClass.isEnum()) { fieldType = FieldType.basic; } else { final ExcelExport excelExport = field.getAnnotation(ExcelExport.class); if (excelExport != null) { fieldType = FieldType.object; if (excelExport.justExport()) { fieldType = FieldType.basic; } if (excelExport.separateSheet()) { fieldType = FieldType.objectSeparateSheet; } } } fieldsTypeCache.put(field, fieldType); } return fieldType; } 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 getFieldType() throws Exception { final ClassFields classFields = new ClassFieldsDefault(TestClass.class); final Iterator<Field> fields = classFields.getFields(); final Field firstField = fields.next(); Assert.assertEquals("Check basic field type", FieldType.basic, ExcelFieldService.getFieldType(firstField)); final Field secondField = fields.next(); Assert.assertEquals("Check type class for a List", FieldType.basic, ExcelFieldService.getFieldType(secondField)); final Field thirdField = fields.next(); Assert.assertEquals("Check basic field type for Object", FieldType.basic, ExcelFieldService.getFieldType(thirdField)); final Field fourthField = fields.next(); Assert.assertEquals("Check objectSeparateSheet field type Object", FieldType.objectSeparateSheet, ExcelFieldService.getFieldType(fourthField)); }