user8578415
user8578415

Reputation: 421

How do I automatically change method/class access levels in IntelliJ?

A lot of the time, I start out with methods being public and then reducing them to the lowest levels needed after I finish, but that's kind of tedious. Is there a way to automatically change all the privacy modifiers (for both classes and methods) to the lowest ones possible all at once?

Upvotes: 4

Views: 2237

Answers (2)

Adam Michalak
Adam Michalak

Reputation: 305

To change generated methods default access modifier:

File -> Settings -> Editor -> Code Style -> Java -> Code Generation -> Default Visibility

There is a different setting for classes:

File -> Settings -> Editor -> File and Code Templates

Upvotes: 2

Andrey
Andrey

Reputation: 16401

It is possible: Analyze | Run inspection by name, and enter Declaration access can be weaker name for the inspection. Then run the inspection for the project and fix all the occurrences in the project by one click in Inspection results tool window.

Upvotes: 5

Related Questions