typesetter:

public Object set$localname$ ($type$ $localname$) { this.$localname$ = $localname$; return this; } 
  • Should a setter return an instance of a class? There are no more differences from the setter that creates the IDE by default. - pavlofff
  • @pavlofff saw in the modding guide for minecraft. It seemed to me interesting. For example, the class planet : planet1.setMass(300).setVelocity(3000).setEccentricity(1.3d); That is, to do several sets in one line. - Herrgott

2 answers 2

When generating a setter, you can choose the builder template instead of the default, and best of all, use lombok

    When you select the autocreate setter ( Code -> Generate -> Setter or ALT + Insert ), the create setter window appears:

    scrn

    You can click on the three dots icon, to the right of the line with the selection of a template ( Template:) and in the wizard that appears, click on the plus sign in the upper left and set your own arbitrary setter generation template.
    There is already a ready template for generating a setter for the Builder pattern - you can select it in the Template drop-down list: Builder

    • Thanks, works - Herrgott