Class To Record
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
Línea de trabajo
Comienza con la Java 17 Records specification enlazada en la issue e inspecciona la Lombok value-to-record implementation referenciada mediante issue #141. Define las precondiciones de las clases compatibles y las transformaciones afectadas antes de implementarlas; el trabajo terminado debe incluir la reestructuración de las clases elegibles, la actualización de las llamadas a getters y la eliminación de los métodos canónicos cuando corresponda.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Java
- Estrellas
- 156
- Forks
- 129
- Merge medio
- 14 h 30 min
- PR fusionados (30 d)
- 43
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de openrewrite/rewrite-migrate-java
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 68/100
openrewrite/rewrite-migrate-java#1246 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 32/100
openrewrite/rewrite-migrate-java#1227 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
OptionalNotPresentToIsEmpty rewrites `!isPresent()` on a non-`java.util.Optional` type, producing uncompilable `isEmpty()`Quizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 70/100
openrewrite/rewrite-migrate-java#1146 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 50/100
openrewrite/rewrite-migrate-java#1119 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
openrewrite/rewrite-migrate-java#1069 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de openrewrite/rewrite-migrate-java
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
utopia-rise/godot-jvm#1004 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
spring-projects/spring-grpc#442 ·
-
Expose numberOfPermits in RateLimiterEvent.toString() and the ratelimiterevents actuator DTOPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
resilience4j/resilience4j#2547 ·
Los mantenedores suelen responder en 9 días
-
Clock.MakeDate continues execution and returns a rolled-over instant after dispatching error on invalid datePosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
mit-cml/appinventor-sources#4155 ·
Los mantenedores suelen responder en 1 día