Class To Record
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với Java 17 Records specification được liên kết trong issue và kiểm tra Lombok value-to-record implementation được tham chiếu qua issue #141. Xác định các điều kiện tiên quyết của class được hỗ trợ và các phép biến đổi bị ảnh hưởng trước khi triển khai chúng; phần hoàn thành phải bao gồm việc tái cấu trúc các class đủ điều kiện, cập nhật các lời gọi getter và loại bỏ các phương thức canonical khi áp dụng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What problem are you trying to solve?
It would be neat to have a capability to convert a class to a record
What precondition(s) should be checked before applying this recipe?
- Java 17+
- Should probably have an arg to specify the type to transform (versus rampantly changing every eligible
classto arecord) - Check for things that would disqualify the
classfrom being arecord, such as:- type must not participate in inheritance
- type must be immutable
- type must not have setters (or maybe make an extra-fancy version of this recipe which can replaces usages of setters with a constructor call) (and/or maybe include a force-override option for this no-setters rule)
- non-static fields must be final or effectively final
- any custom constructor(s) must delegate to another constructor via
this(...)in the first line
Describe the situation before applying the recipe
See Java's specification for Records for context:
https://docs.oracle.com/en/java/javase/17/language/records.html#GUID-6699E26F-4A9B-4393-A08B-1E47D4B2D263
Describe the situation after applying the recipe
- The targeted class should be restructured as a record
- Method invocations of the type's getters should be replaced with record property accessors (eg
getColor()tocolor()) - (bonus points) "canonical"
equals/hashCode/toStringimplementations are removed in favor of the default
Have you considered any alternatives or workarounds?
Any additional context
The implementation for Lombok value to record likely has some useful code to reference/reuse.
This feels like a problem with many weird edge cases (even beyond what's written above), but even a naive implementation which only handles some of those scenarios could probably still be valuable, and the recipe could grow iteratively from there.
Are you interested in contributing this recipe to OpenRewrite?
Maybe; priority TBD
- Ngôn ngữ chính
- Java
- Star
- 156
- Fork
- 129
- Merge trung bình
- 7 giờ 21 phút
- Pull request đã merge (30 ngày)
- 42
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của openrewrite/rewrite-migrate-java
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
openrewrite/rewrite-migrate-java#1289 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
openrewrite/rewrite-migrate-java#1246 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 32/100
openrewrite/rewrite-migrate-java#1227 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
OptionalNotPresentToIsEmpty rewrites `!isPresent()` on a non-`java.util.Optional` type, producing uncompilable `isEmpty()`Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 70/100
openrewrite/rewrite-migrate-java#1146 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 50/100
openrewrite/rewrite-migrate-java#1119 · 5 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của openrewrite/rewrite-migrate-java
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
wildfly/wildfly-launcher#99 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
traccar/traccar#6076 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Flight SQL JDBC parses boolean properties case-sensitively, silently disabling TLS for useEncryption=TRUECó thể đã có người làm @Arawoof06 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
apache/arrow-java#1357 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
apache/rocketmq-dashboard#6610 ·
Maintainer thường phản hồi trong vòng 3 ngày