Automatically Change Public Private (Java)

I am doing refactoring on code, being translated from other languages ​​into Java, and I want to do it automatically. My problem is that I have many methods that are not private, but are called only in the same class as declared, and I want to make them private. I have many classes, and I think if there is something that can help me do this semi-automatically, I would like to know.

Do you know that I can look for these methods to make them private quickly? I am using Eclipse.

+5
source share
3 answers

Replacing everything is one option.

. private public . , , private. , , : " ?".

, , private , , 99% private . , , , . , .

private - . - , - . .

+8

, , , , , . , , . , eclipse, (ctrl + shift + G), , .

, , , .

+2

Perhaps one of the ways will replace the words "public" with the words "private" on the selected documents and with the function "Replace All". But it has side effects if you have "public" content of some code other than the method signature, for example. inside the line maybe.

After replacing all the selected method signatures, check again to make sure that they are the way you wanted.

+1
source

All Articles