You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the feature As discussed here, it would be nice to either have a new command valToVar or mode of delombok to replace existing usage of lombok.val with final var in the source code. This is intended to move away from lombok.val specifically, leaving all other code, comments and lombok features intact.
public String example() {
- val example = new ArrayList<String>();+ final var example = new ArrayList<String>();
example.add("Hello, World!");
- val foo = example.get(0);+ final var foo = example.get(0);
return foo.toLowerCase();
}
Describe the target audience
Anyone using Java 10/11+, and looking to move away from lombok.val specifically, towards final var, while leaving all other usage of lombok features intact.
Additional context lombok.val was added to reduce boilerplate, and up to Java 10 that was indeed true. With the arrival of final var there is less of a need to use lombok.val, and it can be troublesome for other tools to work with.
To keep things simple support could be limited to Java 11+; that way there's no need to replace val with the actual type on Java 8.
At present delombok produces the code to a separate target folder; instructions can be provided to move the altered files back into the source folder to complete the phase out of lombok.val. Even better if replacement could be done in place, but that's optional.
The text was updated successfully, but these errors were encountered:
@rzwitserloot from an end user perspective this has been covered through a new OpenRewrite recipe. The documentation is not yet up, but is it's now possible to phase out lombok.val with their Maven or Gradle plugin.
Question then becomes what you want to do with the issue on this project. You can for instance refer to the implementation at OpenRewrite from the lombok documentation, or keep this issue open if you still plan to implement this yourselves. Either approach could open the door to eventual deprecation (with optional removal), if that's the way you want to go.
Describe the feature
As discussed here, it would be nice to either have a new command
valToVar
or mode ofdelombok
to replace existing usage oflombok.val
withfinal var
in the source code. This is intended to move away fromlombok.val
specifically, leaving all other code, comments and lombok features intact.Describe the target audience
Anyone using Java 10/11+, and looking to move away from
lombok.val
specifically, towardsfinal var
, while leaving all other usage of lombok features intact.Additional context
lombok.val
was added to reduce boilerplate, and up to Java 10 that was indeed true. With the arrival offinal var
there is less of a need to uselombok.val
, and it can be troublesome for other tools to work with.To keep things simple support could be limited to Java 11+; that way there's no need to replace
val
with the actual type on Java 8.At present delombok produces the code to a separate target folder; instructions can be provided to move the altered files back into the source folder to complete the phase out of
lombok.val
. Even better if replacement could be done in place, but that's optional.The text was updated successfully, but these errors were encountered: