I want my eclipse to return this
in a generated setter. This would be very useful for the Builder-Pattern
What eclipse does by default:
public void set{uppercase_field_name}({field_type} {field_name}) {
this.name = name;
}
What i want eclipse to do:
public {class_type} set{uppercase_field_name}({field_type} {field_name}) {
this.name = name;
return this;
}
I found some templates that can be modified under:
Preferences -> Java -> Code Style -> Code Templates
But it is only possible to edit the body of the setter and not the setter signature.
I found the answer very quickly after i googled some more:
Generate setters that return self in Eclipse
I find this approach even better, because i don't have to apply the build pattern every time i generate setters. Which by convention should always be void
.
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.