Formatting Java record fields similar to classes with Intellij IDEA

Viewed 53

I have the following code:

record FooBar(@NotNull String foo, @NotNull Integer bar) {
}

I'd like Intellij IDEA to format it to:

record FooBar(

    @NotNull 
    String foo, 

    @NotNull 
    Integer bar

) {
}

Is this possible?

The closest I was able to get is:

record FooBar(
    @NotNull String foo, 
    @NotNull Integer bar
) {
}

which is not ideal as number of annotations can vary.

The options I used to get to this result are

Record components   Wrap always
Align when multiline    true
New line after '('  true
Place ')' on new line   true
2 Answers

Currently this doesn't seem to be supported - I've opened a ticket on JetBrains issue tracker.

By checking checkbox "New Line after '(' as shown below:

enter image description here

Related