require a blank line between fields if annotations are on separate lines?
Asked Answered
C

1

6

Basically I want different styles depending on annotation count, e.g.

class Foo {
  @Autowire private MyService myService;
  @Autowire private MyOtherService service;

  ...
 }

but if I have more annotations require a space

@Entity
class Bar {
  @Id
  @NotNull
  @Column(...)
  private Long id;

  @NotNull
  @NotEmpty
  @Column(...)
  private String description;
}

can I coerce IDEA into formatting Java for these 2 styles?

Crab answered 10/11, 2014 at 18:42 Comment(0)
D
-2

Under Editor > Code Style > Java > Wrapping and Braces, specify field annotations to "Wrap Always" and tick the "Do not wrap after single annotation" box.

Graphic:

enter image description here

Dwell answered 10/11, 2014 at 18:53 Comment(2)
I don't think that fixes my problem of forcing a newline if multiple annotations.Crab
That's something related specific to a field, actually, but it changes it unconditionally.Dwell

© 2022 - 2024 — McMap. All rights reserved.