Skip to content

Commit 6e6bd00

Browse files
jjohnstnmerks
authored andcommitted
Update convert to record rules for conversion
- update rules to allow for override of equals(), hashCode() and toString() methods
1 parent 8717686 commit 6e6bd00

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

news/4.39/jdt.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ Javadoc pop‑up shown after activating the proposal
6969
A new refactoring has been added: `Right-click` -> `Refactoring` -> `Convert Class to Record...`, which will convert an appropriate class into a record.
7070

7171
1. The class must have only one or more private instance field members that are all initialized in a single constructor by simple assignment and no static members.
72-
2. The class must have at most one getter method per instance field that simply returns the field value and no other methods.
72+
2. The class must have at most one getter method per instance field that simply returns the field value.
7373
3. The class can only extend Object and cannot implement any interface.
74+
4. The class may override `equals()`, `hashCode()`, or `toString()` from Object and these will be copied into the record but it cannot have any other methods except for the aforementioned constructor and getter methods.
7475

7576
The refactoring may note that the conversion is not possible or issue a warning before conversion:
7677
for example, if there is a field that does not have a getter, a warning will be issued that the field will be exposed via an accessor and the user may choose to continue or not.

0 commit comments

Comments
 (0)