自超类自动生成构建器骨架(使用Lombok和Java)

huangapple 未分类评论49阅读模式
英文:

Auto generate builder skeleton from superclass (Lombok & Java)

问题

我想根据Java模型从构建器中生成"骨架代码"。之所以这样做,是因为我们拥有大量嵌套的数据模型,我们希望在模拟存储库测试中对它们进行验证,而手动创建它们是一项耗时的任务。

因此,举个例子:

我想从以下代码生成:

  1. @Getter
  2. @Builder
  3. public class Widget {
  4. private final String name;
  5. private final int id;
  6. }

到这个样子:

  1. Widget testWidget = Widget.builder()
  2. .name("")
  3. .id()
  4. .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:

  1. @Getter
  2. @Builder
  3. public class Widget {
  4. private final String name;
  5. private final int id;
  6. }

To this:

  1. Widget testWidget = Widget.builder()
  2. .name("")
  3. .id()
  4. .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

huangapple
  • 本文由 发表于 2020年4月8日 19:35:21
  • 转载请务必保留本文链接:https://java.coder-hub.com/61099715.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定