ExcelFieldService { public static Class getFieldClass(final Field field) { Class fieldClass = null; if (fieldsClassCache.get(field) != null) { fieldClass = fieldsClassCache.get(field); } else { if (isCollection(field)) { final ParameterizedType genericListType = (ParameterizedType) field.getGenericType(); try { fieldClass = Class.forName(genericListType.getActualTypeArguments()[0].getTypeName()); } catch (ClassNotFoundException e) { logger.error("getFieldClass Error!", e); } } else { fieldClass = field.getType(); } fieldsClassCache.put(field, fieldClass); } return fieldClass; } 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 getFieldClass() 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 class", Long.class, ExcelFieldService.getFieldClass(firstField)); final Field secondField = fields.next(); Assert.assertEquals("Check field class for a List", String.class, ExcelFieldService.getFieldClass(secondField)); }