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

feat: add support for Java records #460

Merged
merged 5 commits into from
Apr 10, 2021

Conversation

clementdessoude
Copy link
Contributor

What changed with this PR:

Add support for Java records. There might be some formatting issues with some edge cases but it should be almost good ! :)

Example

// Input
public record Pet(
@NotNull String name, int age, String... others, Object @Nullable... errorMessageArgs
    ) {
public Pet {
    if (age < 0) {
    throw new IllegalArgumentException("Age cannot be negative");
    }

    if (name == null || name.isBlank()) {
    throw new IllegalArgumentException("Name cannot be blank");
    }
    }

public void test() {}
    }

public record Pet(
@NotNull String name, int age, String... others, Object @Nullable... errorMessageArgs
    ) {

    }

public record Pet(

    ) {

    }

public record Pet(

    ) {
public void test() {}
    }



// Output
public record Pet(
  @NotNull String name, int age, String... others, Object @Nullable... errorMessageArgs
) {
  public Pet {
    if (age < 0) {
      throw new IllegalArgumentException("Age cannot be negative");
    }

    if (name == null || name.isBlank()) {
      throw new IllegalArgumentException("Name cannot be blank");
    }
  }

  public void test() {}
}

public record Pet(
  @NotNull String name, int age, String... others, Object @Nullable... errorMessageArgs
) {}

public record Pet() {}

public record Pet() {
  public void test() {}
}

Relative issues or prs:

Closes #433

@clementdessoude clementdessoude merged commit 98b1fb5 into jhipster:main Apr 10, 2021
@clementdessoude clementdessoude deleted the feat/record-support branch April 10, 2021 14:11
@pascalgrimaud
Copy link
Member

@clementdessoude : can we do a release with this, plz?

@clementdessoude
Copy link
Contributor Author

Thanks for taking care of it @pascalgrimaud !

@pascalgrimaud
Copy link
Member

You're welcome @clementdessoude
Thanks for your work here

@linco95 linco95 mentioned this pull request Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support preview feature: Records
2 participants