In the upcoming Java 14 release scheduled for March, a concept called records will be introduced as a preview feature. This will come as a relief to those developers currently using their IDEs to auto-generate getters, public constructors, etc. for this type of class. A record is an immutable transparent carrier for a fixed set of values known as components. For those familiar with the Scala language, records appear to be very similar to case classes.
To get a better idea of what this capability would give you, just imagine only having to write the following instead of an equivalent class without methods for getters, equals/hashcode, public constructors, and toString.
public record TopLevelUpsertNode( Project project, NodeSelector nodeSelector, CreateNode createNode, TopLevelUpdateNode topLevelUpdateNode)
To access this language feature, compile with the preview flag as in the following example:
java –enable-preview -source 14 TopLevelUpsertNode.java
I look forward to tinkering with this feature in this release.