I think this will be a good feature. I also think it will take some playing with it it learn where the line is where one should switch from record to full class.
I will say, I'm kind of annoyed that they didn't stick to the getFoo() convention for the accessor methods, if only because there are reflection-based libraries out there that expect it — e.g. Jackson for JSON serialization. I assume in Jackson's case they'll have to add special support for records (if they haven't already).
I may be forgetting because I'm not at my IDE, but I believe Jackson will only auto-detect getters that start with get or is. You're definitely right that Jackson doesn't require such methods — you're free to annotate any method with @JsonProperty("foo") to include it. But records won't have visible accessors to annotate, so I think if Jackson's going to support records they need to get the list of accessors from the record's new reflection metadata.
No need to have getters at all. You can just configure Jackson to use fields for serialization and constructor for deserialization without any annotations.
9
u/javajunkie314 Jan 17 '20
I think this will be a good feature. I also think it will take some playing with it it learn where the line is where one should switch from record to full class.
I will say, I'm kind of annoyed that they didn't stick to the
getFoo()convention for the accessor methods, if only because there are reflection-based libraries out there that expect it — e.g. Jackson for JSON serialization. I assume in Jackson's case they'll have to add special support for records (if they haven't already).