Shortcut for calling all the setter methods on an object in Eclipse?
I do not want to do that 150 times
I'm not aware of any Eclipse feature that will help you here.
You could fall back to using something clunky like emacs keyboard macros or perl scripting to massage the source code outside of Eclipse.
Your other option (though it probably won't be productive ...) is to request that the cumbersome API be revised; e.g. to support the "builder" pattern.
From my experience last time , I cannot find eclipse has such feature .The most that I can do is open the Type Hierarchy
View (by pressing F4 when viewing that class ), and then sort by the method name of that class and copy all the setters for further edit.
Or , you can use reflection to find out all the methods of this class , and print out the setter calls . Suppose this class is called Foo
, you can have something like this:
for (Method m : Foo.class.getMethods()) {
if (m.getName().startsWith("set")) {
System.out.println(String.format("instanceName.%s(\"valOne\");", m.getName()));
}
}
See this question: Generate all setXXX calls of a POJO in Eclipse?
It has a great and simple way of doing what you want to do.
Oh and try to ignore the haters!
If you're using IntelliJ, check out this plugin:
https://plugins.jetbrains.com/plugin/9360-generateallsetter