Kilo icon indicating copy to clipboard operation
Kilo copied to clipboard

Add support for record types

Open gk-brown opened this issue 3 years ago • 0 comments

Java 15 introduced records as a preview feature:

https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/lang/Record.html

BeanAdapter should be updated to support reading from record types (e.g. via a static inner RecordAdapter class that implements Map) as well as coercing loosely typed (i.e. map) data to record instances.

A new isRecord() method will be added to Class that can be used to identify record types. A getRecordComponents() method will also be added to Class that will return the list of the record's "components" (i.e. fields/properties). Since records can have convenience constructors, this component list can be use to identify the canonical constructor that should be used to instantiate the record.

Record components can be annotated, so it may be possible/useful to support the Key annotation on these values.

This change will require Java 17 as a baseline version (first LTS release to support records).

gk-brown avatar Mar 09 '21 22:03 gk-brown