@Test public void shouldFindFieldNameGivenTheHeader() { List<String> headers = new ArrayList<String>() {{ add("mandatory string field"); add("mandatoryIntField"); }}; ModelClass modelClass = new ModelClass(DummyImportable.class); final String[] mappings = modelClass.getFieldNameMappings(headers.toArray(new String[headers.size()])); assertThat(mappings[0], is("mandatoryStringField")); assertThat(mappings[1], is("mandatoryIntField")); }
public String[] getFieldNameMappings(String[] headers) { List<String> fieldMappings = new ArrayList<>(); for (String header : headers) { Field importField = findImportFieldWithName(header); if (importField != null) { String nestedProperty = importField.getNested(); if (nestedProperty.isEmpty()) { fieldMappings.add(importField.getField().getName()); } else { fieldMappings.add(importField.getField().getName() + "." + nestedProperty); } } else { fieldMappings.add(null); } } return fieldMappings.toArray(new String[fieldMappings.size()]); }
ModelClass { public String[] getFieldNameMappings(String[] headers) { List<String> fieldMappings = new ArrayList<>(); for (String header : headers) { Field importField = findImportFieldWithName(header); if (importField != null) { String nestedProperty = importField.getNested(); if (nestedProperty.isEmpty()) { fieldMappings.add(importField.getField().getName()); } else { fieldMappings.add(importField.getField().getName() + "." + nestedProperty); } } else { fieldMappings.add(null); } } return fieldMappings.toArray(new String[fieldMappings.size()]); } }
ModelClass { public String[] getFieldNameMappings(String[] headers) { List<String> fieldMappings = new ArrayList<>(); for (String header : headers) { Field importField = findImportFieldWithName(header); if (importField != null) { String nestedProperty = importField.getNested(); if (nestedProperty.isEmpty()) { fieldMappings.add(importField.getField().getName()); } else { fieldMappings.add(importField.getField().getName() + "." + nestedProperty); } } else { fieldMappings.add(null); } } return fieldMappings.toArray(new String[fieldMappings.size()]); } ModelClass(Class<? extends Importable> clazz);  ModelClass(Class<? extends Importable> clazz, boolean acceptExtraHeaders); }
ModelClass { public String[] getFieldNameMappings(String[] headers) { List<String> fieldMappings = new ArrayList<>(); for (String header : headers) { Field importField = findImportFieldWithName(header); if (importField != null) { String nestedProperty = importField.getNested(); if (nestedProperty.isEmpty()) { fieldMappings.add(importField.getField().getName()); } else { fieldMappings.add(importField.getField().getName() + "." + nestedProperty); } } else { fieldMappings.add(null); } } return fieldMappings.toArray(new String[fieldMappings.size()]); } ModelClass(Class<? extends Importable> clazz);  ModelClass(Class<? extends Importable> clazz, boolean acceptExtraHeaders); void validateHeaders(List<String> headers); String[] getFieldNameMappings(String[] headers); Field findImportFieldWithName(final String name); }
ModelClass { public String[] getFieldNameMappings(String[] headers) { List<String> fieldMappings = new ArrayList<>(); for (String header : headers) { Field importField = findImportFieldWithName(header); if (importField != null) { String nestedProperty = importField.getNested(); if (nestedProperty.isEmpty()) { fieldMappings.add(importField.getField().getName()); } else { fieldMappings.add(importField.getField().getName() + "." + nestedProperty); } } else { fieldMappings.add(null); } } return fieldMappings.toArray(new String[fieldMappings.size()]); } ModelClass(Class<? extends Importable> clazz);  ModelClass(Class<? extends Importable> clazz, boolean acceptExtraHeaders); void validateHeaders(List<String> headers); String[] getFieldNameMappings(String[] headers); Field findImportFieldWithName(final String name);  }