I have same set of code that I should write for each variable that I declare in class similar to getters and setters. Can I customize lombok to do this, or is there any other way to do this?
public class Test {
String t1;
String t2;
These are the repetitive methods that I write for every variable that I declare.
public String TestT1() {
test(t1);
return t1;
}
public String TestT2() {
test(t2);
return t2;
}
private void test(String t1) {
System.out.println("For Example");
}
}
You can do it using Custom Templates in Eclipse IDE. Not exact same but it will help.
Go to Windows > Preferences > Java > Editor > Templates .
Click on New button add template code as given in screenshot.
public String Test${arg:localVar}() { test(${arg:localVar}); return ${arg:localVar}; }
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.