Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this questionWondering if there is tool to assist this kind of refactoring.
Eclipse is an awesome IDE!
... or...
In Netbeans...
Eclipse has the functionality of generate getters and setters.
Source > Generate setters and getters
Source: Generate Getters and Setters
eclipse provides this. You can use my plugin as well : https://stackoverflow.com/questions/2733311/copy-field-and-methods/2734647#2734647.
It's a standard feature of the eclipse IDE (and of other IDEs too, I suppose).
Shortcut: ALT+s -> r shows the getter/setter dialog (if a class with class members was selected)
BTW - autogenerating getter/setter stubs for class members is not a refactoring.
Code refactoring is "a disciplined way to restructure code", undertaken in order to improve some of the nonfunctional attributes of the software. (wikipedia)
Autogenerating those stubs does not restructure the (existing) code. It automatically adds method implementations. And, if we look at eclipse, we don't find the according action in the list of refactorings (additional hint).
Further Reading: Self Encapsulate Field
Depending on what IDE you use, this is a standard feature provided. For instance, in Netbeans - right click on your java class and choose Refactor -> Encapsulate Fields. You can additionally select the accessors visibility, order of appearance and insert point.
精彩评论