[英]eclipse scripting: one click, add constructors and getter + setters to a POJO
Is there a way to call eclipse Source code generators from a script/ add on? 有没有一种方法可以从脚本/插件中调用eclipse源代码生成器?
Many times I make a pojo, like: 我很多次打pojo,例如:
public class StepState {
private boolean success;
private BuildType buildType;
private String summary;
private String detail;
}
Want to convert it to : 想要将其转换为:
public class StepState {
private boolean success;
private BuildType buildType;
private String summary;
private String detail;
public StepState() {
super();
}
public StepState(boolean success, BuildType buildType, String summary, String detail) {
super();
this.success = success;
this.buildType = buildType;
this.summary = summary;
this.detail = detail;
}
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public BuildType getBuildType() {
return buildType;
}
public void setBuildType(BuildType buildType) {
this.buildType = buildType;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public String getDetail() {
return detail;
}
public void setDetail(String detail) {
this.detail = detail;
}
}
Meaning add a constructor from suer class without any arguments. 意思是从suer类中添加一个没有任何参数的构造函数。 Add a constructor with all elements, add getters and setters for all fields. 添加具有所有元素的构造函数,为所有字段添加getter和setter。 I guess there are cases like if this class extends another class ... but I want some assumptions to be made, one click and output. 我想有些情况是如果该类扩展了另一类...但是我希望做出一些假设,单击并输出。 Later I can review and edit as needed. 稍后,我可以根据需要进行审查和编辑。
Right now I need to go menu Source, select "Generate Constructors Using Superclass", then "Generate Getters and Setters", and in each step make default choices like select all fields, click okay... Is there a way to script eclipse and call its features, on a new POJO I make ? 现在,我需要进入“源代码”菜单,选择“使用超类生成构造函数”,然后选择“生成Getter和Setters”,并在每一步中进行默认选择,例如选择所有字段,单击“确定”。调用它的功能,在我制作的新POJO上?
I do not want to see the dialog boxes etc. Just one click and all 3 tasks done. 我不想看到对话框等。只需单击一下即可完成所有3个任务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.