W Javie 14 wchodzą rekordy w wersji preview https://openjdk.java.net/jeps/359 przy czym nie ma wprost propertiesów:
Non-Goals
It is not a goal to declare "war on boilerplate"; in particular, it is not a goal to address the problems of mutable classes using the JavaBean naming conventions. It is not a goal to add features such as properties, metaprogramming, and annotation-driven code generation, even though they are frequently proposed as "solutions" to this problem.
Rekordy są niemutowalne:
Records provide a compact syntax for declaring classes which are transparent holders for shallowly immutable data.
Składnia jest zwięzła:
record Point(int x, int y) { } // tadam! tylko tyle wystarczy
Z automatu generowane są pola, gettery, konstruktor, equals, hashCode, toString i jeszcze jakieś dodatkowe rzeczy:
a record acquires many standard members automatically:
- A private final field for each component of the state description;
- A public read accessor method for each component of the state description, with the same name and type as the component;
- A public constructor, whose signature is the same as the state description, which initializes each field from the corresponding argument;
- Implementations of equals and hashCode that say two records are equal if they are of the same type and contain the same state; and
- An implementation of toString that includes the string representation of all the record components, with their names.
Reflection API
The following public methods will be added to java.lang.Class:
- RecordComponent[] getRecordComponents()
- boolean isRecord()
Docelowo mogą być wykorzystane do pattern matchingu (chodzi o dekonstrukcję klas, nie regexy) w Javie: https://cr.openjdk.java.net/~briangoetz/amber/pattern-match.html