Enum usage explain?
aleksandar-stefanovic-tamedia opened this issue · comments
Maybe I'm missing something. Class into which I want to parse is created. One of the columns is defined:
@ExcelCellName("interval")
private Interval interval;
With enum Interval:
@AllArgsConstructor
public enum Interval {
DAY("Day"),
MONTH("Month"),
YEAR("Year");
private String interval;
}
But after parsing field interval is always null. What I'm missing here?
Managed to solve it. I just added custom casting with all needed types/enums.
public class BouCasting implements Casting {
@Override
public Object castValue(Field fieldType, String value, int row, int column, PoijiOptions options) {
Object o = new Object();
if (fieldType.getType() == String.class) {
o = value;
} else if (fieldType.getType() == Integer.class) {
o = Integer.valueOf(value);
} else if (fieldType.getType() == Boolean.class) {
o = Boolean.valueOf(value);
} else if (fieldType.getType() == Interval.class) {
o = Interval.fromString(value);
} else if (fieldType.getType() == Type.class) {
o = Type.fromString(value);
}
return o;
}
}
Hi @aleksandar-stefanovic-tamedia ,
glad you to fix it ! I was going to say that you can implement your custom casting to make it possible.