diff --git a/src/main/java/com/poiji/bind/mapping/HSSFUnmarshaller.java b/src/main/java/com/poiji/bind/mapping/HSSFUnmarshaller.java index 0c2b5c1..d48f01e 100644 --- a/src/main/java/com/poiji/bind/mapping/HSSFUnmarshaller.java +++ b/src/main/java/com/poiji/bind/mapping/HSSFUnmarshaller.java @@ -290,7 +290,7 @@ private FieldAnnotationDetail getFieldColumn(final Field field) { List 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()); @@ -317,7 +317,6 @@ public Integer findTitleColumn(ExcelCellName excelCellName) { .map(Map.Entry::getValue) .orElse(null); } - return null; } diff --git a/src/test/java/com/poiji/bind/mapping/HSSFUnmarshallerTest.java b/src/test/java/com/poiji/bind/mapping/HSSFUnmarshallerTest.java index 92fc56d..7f39071 100644 --- a/src/test/java/com/poiji/bind/mapping/HSSFUnmarshallerTest.java +++ b/src/test/java/com/poiji/bind/mapping/HSSFUnmarshallerTest.java @@ -24,19 +24,21 @@ public HSSFUnmarshallerTest(String fieldName) throws NoSuchFieldException { @Parameterized.Parameters(name = "{index}: ({0})={1}") public static Iterable 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); diff --git a/src/test/java/com/poiji/deserialize/model/InventoryData.java b/src/test/java/com/poiji/deserialize/model/InventoryData.java index ef02aa2..fc7f26a 100644 --- a/src/test/java/com/poiji/deserialize/model/InventoryData.java +++ b/src/test/java/com/poiji/deserialize/model/InventoryData.java @@ -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; } @@ -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); }