Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

in IntelliJ Java's Code Style how do we set it up to require blank line between annotated fields and no blank line between non-annotated fields

When the fields have no annotation I want to keep them together

public class MyPojo {

  public String a;
  public String b;
}

but if a field is annotated I want a blank line above the annotation

public class MyPojo {

  @JsonProperty("a")
  public String a;

  @JsonProperty("b")
  public String b;
}

is there a configuration of settings in IntelliJ that would give me this behavior? my current relevant settings are below:

  • Preferences
    • Editor
      • Code Style
        • Java
          • Wrapping and Braces
            • Field annotations: Wrap always
              • Do not wrap after single annotation: unchecked
          • Blank Lines
            • Keep Maximum Blank Lines
              • In declarations: 1
            • Minimum Blank Lines
              • Around field in interface: 0
              • Around field: 0
like image 733
Jon Erickson Avatar asked Nov 08 '22 16:11

Jon Erickson


1 Answers

I tried to look for all possible options in formatting settings but could not find anything that can let us have a blank line before annotations. I could just found that we can add a space after annotations but nothing is there for the line.

I am also interested if you could find it. :)

like image 99
ACloudRoamer Avatar answered Nov 14 '22 23:11

ACloudRoamer