Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lombok.experimental.FieldDefaults #175

Open
timtebeek opened this issue Jan 26, 2023 · 0 comments
Open

Remove lombok.experimental.FieldDefaults #175

timtebeek opened this issue Jan 26, 2023 · 0 comments
Labels
recipe Recipe requested

Comments

@timtebeek
Copy link
Contributor

@FieldDefaults is an experimental Lombok feature that along with a few sibling annotations allows users to forgo adding field modifiers to individual fields.

So

import lombok.AccessLevel;
import lombok.experimental.FieldDefaults;
import lombok.experimental.NonFinal;
import lombok.experimental.PackagePrivate;

@FieldDefaults(makeFinal=true, level=AccessLevel.PRIVATE)
public class FieldDefaultsExample {
  public final int a;
  int b;
  @NonFinal int c;
  @PackagePrivate int d;
  
  FieldDefaultsExample() {
    a = 0;
    b = 0;
    d = 0;
  }
}

Becomes

public class FieldDefaultsExample {
  public final int a;
  private final int b;
  private int c;
  final int d;
  
  FieldDefaultsExample() {
    a = 0;
    b = 0;
    d = 0;
  }
}

which if you were to ask me does not improve readability for this small sample.

Given that it's an experimental feature, with an uncertain future given the last update ("this feature will not be leaving experimental in its current state"), there's bound to be an audience for removing these annotations with their one to one replacement modifiers.

I've placed the issue here as we have other lombok recipes/issues in this repository, and newer versions of Lombok or Java might have it make sense to be part of rewrite-migrate-java.

@timtebeek timtebeek added the recipe Recipe requested label Jan 26, 2023
@timtebeek timtebeek moved this to Recipes Wanted in OpenRewrite Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
recipe Recipe requested
Projects
Status: Recipes Wanted
Development

No branches or pull requests

1 participant