简体   繁体   中英

Eclipse Refactoring - Replace Java getters & setters with direct field access

For our pure data classes, we don't use getters or setters. When refactoring old code, I would like to be able to quickly replace (typically Eclipse-generated) calls to getters & setters with direct field access.

Is there a plugin that does that?

Note : I'm not interested in the pros & cons of encapsulation or not, that has already been discussed too many times .

So, I would like to replace:

myData.setValue(17);
int value = myData.getValue();

with:

myData.value = 17;
int value = myData.value;

You can use the existing inline method refactoring. Just make the field in question public and then execute that refactoring. If your code base is too large to do this by hand, you might have a look at How to execute inline refactoring programmatically using JDT/LTK?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM