IntelliJ IDEA 2021.1 Help

Replace Constructor with Builder dialog

Refactor | Replace Constructor with Builder

The Replace Constructor with Builder refactoring helps hide a constructor, replacing its usages with the references to a newly generated builder class, or to an existing builder class.

ItemDescription

Parameters to pass to the builder

ParameterThis column shows the list of parameters detected in the constructor, which will be replaced with the builder fields.
Field nameThis editable column shows the list of suggested field names in the builder.
Setter nameThis editable column shows the list of suggested setter names in the builder.
Default valueUse this editable column to initialize the fields with the default values.
Optional setterIf the specified default value of a field matches the parameter value in the constructor invocation, then selecting this checkbox results in omitting setter method for this field in the builder invocation.
If this checkbox is not selected, the corresponding setter method will be shown anyway.

Builder name and location

Create newClick this radio button to generate a new builder class, with the specified name and destination package.
Builder class nameThis editable field shows the suggested name of the new builder class to ge generated. You can accept default, or type a new one.
Package for new builderType the name of the destination package, or click the browse button, and locate it in the Choose Destination Package dialog box.
If the desired package doesn't exist, click Icons actions new folder to create a new one.
Use existingClick this radio button to specify an existing builder class.
Builder class nameType here the fully qualified name of the desired builder class that already exists in your project, or click the browse button and find it either by name, or in the project tree view.
Last modified: 08 March 2021