vaadin / docs

Official documentation for Vaadin and Hilla.
https://vaadin.com/docs
Other
30 stars 184 forks source link

Suggestion for improvement: Usage of java "records" as results of Endpoints #2017

Open bwajtr opened 1 year ago

bwajtr commented 1 year ago

In the following chapter: https://hilla.dev/docs/lit/start/in-depth/type-safe-server-access-with-endpoints/#creating-the-crm-endpoint

The part about the Endpoint result type (definition of CrmData.java) suggests the following:

Within the same class, create an inner class, CrmData. Because this class is only used as a data wrapper, it doesn’t need data encapsulation and the associated getters and setters. Instead, it uses public fields.

I think it's worth noting in this part that if the developer is using Java 17 (which will be the minimum version for Hilla 2, right?), using the Java "record" as the return type from the endpoint would be another working option

platosha commented 1 year ago

Thanks for the suggestion. As far as I remember, Java records are not supported in the default source-based parser, therefore using records as of today requires enabling the hillaEngine feature-flag that enables the new multi-module bytecode parser.

Let us consider suggesting records after making the multi-module parser stable.