I have several classes like in the following example:
abstract class AClass {
boolean validate(){
return true;
}
}
When another class extends AClass
, I do it like this:
class BClass extends AClass {
@Override
boolean validate() {
if (!super.validate()) {
return false;
}
// TODO validate
return true;
}
}
Is there an eclipse plugin that generates that code for me when I create a new class from the menu(File>New>Class)?
I'm thinking to use an annotation
@Target(ElementType.METHOD)
@interface Code {
String content();
}
And add it to the method:
abstract class AClass {
@Code(content = "\tif (!super.validate()) {\r\n"
+ "\t\treturn false;\r\n"
+ "\t}\r\n"
+ "\t// TODO validate\r\n"
+ "\treturn true;")
boolean validate() {
return true;
}
}
The plugin should look for the annotation and generate the code in the newly created class.