Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How extract private static constant in Intellij Idea?

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?

like image 454
Cherry Avatar asked Oct 27 '13 06:10

Cherry


People also ask

How do I extract files in IntelliJ?

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.

How do I extract a class in IntelliJ?

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.

What is Generify in IntelliJ?

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.


1 Answers

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.

like image 154
pbaranski Avatar answered Sep 21 '22 12:09

pbaranski