I have a fixed length record bean for beanio
as follows:
@Record
public class RecordBean {
@Field(at = 0, length = 3)
private String field1;
@Field(at = 3, length = 10)
private String field2;
//etc
}
Now I want to use that bean also as a transfer object within my application, and later unmarshal it to the fixedLength record using beanio.
Problem: when I access the fields of the RecordBean
, I can never be sure if the field may be null
, as I create the object myself:
RecordBean r = new RecordBean();
r.getField1(); //may be null
Question: can I somehow initialize the bean using beanio
with default values? Eg an empty string that has the exact length given in the @Field
annotation?
I could as a workaround wrap each getter in StringUtils.defaultString(value)
but thats much boilerplate code.