Skip to content

Commit

Permalink
add empty checkers
Browse files Browse the repository at this point in the history
  • Loading branch information
ozlerhakan committed Feb 25, 2024
1 parent 94497a5 commit 5ffadf3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/main/java/com/poiji/bind/mapping/HSSFUnmarshaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ private FieldAnnotationDetail getFieldColumn(final Field field) {

List<Integer> columns = indexToTitle.entrySet().stream()
.filter(entry -> pattern.matcher(
entry.getValue().replaceAll("@[0-9]+", ""))
entry.getValue().replaceAll("@[0-9]+", ""))
.matches())
.map(Map.Entry::getKey)
.collect(Collectors.toList());
Expand All @@ -317,7 +317,6 @@ public Integer findTitleColumn(ExcelCellName excelCellName) {
.map(Map.Entry::getValue)
.orElse(null);
}

return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,21 @@ public HSSFUnmarshallerTest(String fieldName) throws NoSuchFieldException {

@Parameterized.Parameters(name = "{index}: ({0})={1}")
public static Iterable<Object[]> queries() {
return List.of(new Object[][]{
return List.of(new Object[][] {
{
"id"
},
{
"author"
},
{ "empty" }
});
}

@Test
public void shouldFindTitleColumn() {
HSSFUnmarshallerFile hssfUnmarshallerFile = new HSSFUnmarshallerFile(null, PoijiOptions.PoijiOptionsBuilder.settings().build());
HSSFUnmarshallerFile hssfUnmarshallerFile = new HSSFUnmarshallerFile(null,
PoijiOptions.PoijiOptionsBuilder.settings().build());

Integer titleColumn = hssfUnmarshallerFile.findTitleColumn(annotation);

Expand Down
9 changes: 7 additions & 2 deletions src/test/java/com/poiji/deserialize/model/InventoryData.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public class InventoryData {
@ExcelCellName(value = "", expression = "Author|Composer")
private String author;

@ExcelCellName(value = "")
private String empty;

public void setId(Integer id) {
this.id = id;
}
Expand All @@ -32,8 +35,10 @@ public String toString() {

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
InventoryData that = (InventoryData) o;
return Objects.equals(id, that.id) && Objects.equals(author, that.author);
}
Expand Down

0 comments on commit 5ffadf3

Please sign in to comment.