ExcelFieldService { public static String getFieldName(final Class clazz, final Field field, final TranslateService translateService) { final ExcelExport excelExport = field.getAnnotation(ExcelExport.class); if (excelExport != null) { String label = null; if (excelExport.useTranslation()) { label = translateService.getTranslation(clazz, field); } if (!excelExport.name().isEmpty()) { if (StringUtils.isEmpty(label)) { return excelExport.name(); } else { return excelExport.name() + " - " + label; } } } return field.getName(); } 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 getFieldName() throws Exception { final ClassFields classFields = new ClassFieldsDefault(OtherClass.class); final Iterator<Field> fields = classFields.getFields(); final Field firstField = fields.next(); Assert.assertEquals("Check field name", "valid", ExcelFieldService.getFieldName(null, firstField, null)); final Field secondField = fields.next(); Assert.assertEquals("Check field name", "money", ExcelFieldService.getFieldName(null, secondField, null)); }