英文:
Auto generate builder skeleton from superclass (Lombok & Java)
问题
我想根据Java模型从构建器中生成"骨架代码"。之所以这样做,是因为我们拥有大量嵌套的数据模型,我们希望在模拟存储库测试中对它们进行验证,而手动创建它们是一项耗时的任务。
因此,举个例子:
我想从以下代码生成:
@Getter
@Builder
public class Widget {
private final String name;
private final int id;
}
到这个样子:
Widget testWidget = Widget.builder()
.name("")
.id()
.build();
然后自己填充测试数据。
如果您有Intellij插件或其他建议,请告诉我,这将为我们节省大量时间。
谢谢
英文:
I would like to "generate" skeleton code from builder based on Java models. The reason for this is that we are having large nested data models which we would like to validate in our mocked repository tests and it´s a time-consuming process of creating them up.
So for example:
I would like to generate from this:
@Getter
@Builder
public class Widget {
private final String name;
private final int id;
}
To this:
Widget testWidget = Widget.builder()
.name("")
.id()
.build();
And then fill it by myself with test data.
Do you have suggestions of Intellij plugins or anything please let me know, would save a lot of time for us.
Regards
专注分享java语言的经验与见解,让所有开发者获益!
评论