To extract constant I can use ctrl + alt + c, that "extraction" create public constant:
public static final String CONST = "123";
So I need manually type private. Is there a way to extract constant with private scope by default?
To extract method:Press Ctrl+Alt+M or from the main menu, select Refactor | Extract | Method. In the dialog that opens, configure a method options, such as visibility, parameters, and so on. You can also change a name of the method if you need. Click OK.
Select a code fragment that you want to extract into a class. Depending on what you want to extract, from the main menu, select one of the following: Refactor | Extract | Delegate. Refactor | Extract | Method Object.
Generate delegation methods IntelliJ IDEA can generate methods that delegate behavior to the fields or methods of your class. This approach makes it possible to give access to the data of a field or method without directly exposing this field or method.
Hit ctrl+alt+c twice (shows Extract Constant
dialog)
hit alt+v (set default Visibility
to Private
)
hit enter
Done :) The private scope is set default - so you can use constant extraction as before, to change default scope simply repeat steps above with choosing different scope.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With