質問

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?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top