Add support for java records
tymur-berezhnoi opened this issue · 8 comments
It would be awesome to map an xls/xlsx record to a java record, like this one:
public record MyRecord(
@ExcelCellName("Writing code")
String writingCode
) {
}
... but currently Poiji throws an exception:
com.poiji.exception.PoijiInstantiationException: Cannot create a new instance of com.model.MyRecord
at com.poiji.util.ReflectUtil.newInstanceOf(ReflectUtil.java:28)
at com.poiji.bind.mapping.HSSFUnmarshaller.deserializeRowToInstance(HSSFUnmarshaller.java:163)
at com.poiji.bind.mapping.HSSFUnmarshaller.processRowsToObjects(HSSFUnmarshaller.java:97)
at com.poiji.bind.mapping.HSSFUnmarshaller.unmarshal(HSSFUnmarshaller.java:80)
at com.poiji.bind.Poiji.fromExcel(Poiji.java:220)
at com.poiji.bind.Poiji.fromExcel(Poiji.java:196)
....
....
....
....
....
Caused by: java.lang.NoSuchMethodException: com.model.MyRecord.<init>()
at java.base/java.lang.Class.getConstructor0(Class.java:3508)
at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2711)
at com.poiji.util.ReflectUtil.newInstanceOf(ReflectUtil.java:22)
... 108 common frames omitted
Hey @t-jd ,
Thanks for the issue, Poiji does not support new features of Java.
Hi @ozlerhakan
Yep, but anyway, any plans to support new features like java records? It would be super useful if can bind xls row with a java record
It would be good to support indeed @t-jd
Hi @t-jd ,
Do you want to make this changes by yourself in the next release of Poiji? wdyt :)
Hi @ozlerhakan
I will take a look once I have free time, but I don't promise, maybe someone else will do it before me
This will be ready in version 4.0.0 @t-jd Thanks!
right now there are some limits to unable java records on Poiji. This does not mean that we don't add it to Poiji, however, once we handle it, I re open this issue to integrate it.
sorry for necro, any updates for this?