Support for Java 14 Records
It would be nice to be able to use this library with Java 14 records, for example:
public record LineRecord(
@FixedField(offset = 1, length = 42)
String firstStr,
@FixedField(offset = 43, length = 5)
String secondStr
) {}
As it is a lot more declarative than defining traditional POJOs & it automatically implements toString, hashCode and equals.
Maybe an alternative approach could be to add some support for Immutables. This would more or less have the same benefits while maintaining compatibility with Java 8 (Immutables is Java 8).
So far, I tried to create an interface and annotate it like:
// create DTO with setters
@Value.Modifiable
interface LineRecord {
@FixedField(offset = 1, length = 42)
String firstStr();
@FixedField(offset = 43, length = 5)
String secondStr();
}
Problem here being, that methods cannot be annotated with @FixedField.
Hey, @mbechto , it took a little more time to implement it :) anyway, check out the 0.12 version, there is an experimental support of records. I'll close this issue, if you will face some problems using records, please open new issues here.
Thank you for great enhancement proposal!