This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new db8132f  documentation for records (draft)
db8132f is described below

commit db8132fe69a762838a56aefa3eef873dc82379b9
Author: Paul King <[email protected]>
AuthorDate: Thu Oct 28 21:49:36 2021 +1000

    documentation for records (draft)
---
 src/spec/doc/_records.adoc                   | 9 ++++++---
 src/spec/test/RecordSpecificationTest.groovy | 3 +++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/spec/doc/_records.adoc b/src/spec/doc/_records.adoc
index c996a92..8d811af 100644
--- a/src/spec/doc/_records.adoc
+++ b/src/spec/doc/_records.adoc
@@ -56,6 +56,9 @@ for the following rough equivalent:
 
include::../test/RecordSpecificationTest.groovy[tags=record_message_equivalent,indent=0]
 ----
 
+Note the special naming convention for record getters. They are the same name 
as the field
+(rather than the otherwise common JavaBean convention of capitalized with a 
"get" prefix).
+
 Like in Java, you can override the normally implicitly supplied methods
 by writing your own:
 
@@ -153,8 +156,8 @@ Groovy's record feature offering three levels of 
convenience:
 == Other differences to Java
 
 Groovy supports creating record-like classes as well as native records.
-Record-like classes don't extend Java's `Record` class and won't be seen
-by Java as records but will otherwise have similar properties.
+Record-like classes don't extend Java's `Record` class and such classes
+won't be seen by Java as records but will otherwise have similar properties.
 
 The `@RecordBase` annotation (part of `@RecordType`) supports a `mode` 
annotation attribute
 which can take one of three values (with `AUTO` being the default):
@@ -162,7 +165,7 @@ which can take one of three values (with `AUTO` being the 
default):
 NATIVE::
 Produces a class similar to what Java would do. Produces an error when 
compiling on JDKs earlier than JDK16.
 EMULATE::
-Produces a record-like class.
+Produces a record-like class for all JDK versions.
 AUTO::
 Produces a native record for JDK16+ and emulates the record otherwise.
 
diff --git a/src/spec/test/RecordSpecificationTest.groovy 
b/src/spec/test/RecordSpecificationTest.groovy
index 6fbb8fb..85c8552 100644
--- a/src/spec/test/RecordSpecificationTest.groovy
+++ b/src/spec/test/RecordSpecificationTest.groovy
@@ -49,6 +49,9 @@ final class Message extends Record {
     final boolean equals(Object other) { /*...*/ }
 
     final int hashCode() { /*...*/ }
+
+    String from() { from }
+    // other getters ...
 }
 // end::record_message_equivalent[]
 '''

Reply via email to