Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Proposal] Enable Lombok.toBuilder annotation flag in ResourceModel template

未关闭
#331 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
java
领域
tooling

调研方向

从 issue 中链接的 python/rpdk/java/templates/init/guided_aws/ResourceModel.java 开始,检查生成的 ResourceModel 注解是如何组装的。确定是否应默认启用 toBuilder,或将其作为 schema flag 暴露,然后验证生成的 Java model 是否支持所请求的 builder-copy 工作流。

由索引模型根据 Issue 内容生成。

描述

Dear team,

I wonder if you folks would have any concerns about enabling toBuilder attribute for Lombok @Builder by default or with an additional schema flag?

At the moment, ResourceModel template generates non-parametrized @Builder: https://github.com/aws-cloudformation/cloudformation-cli-java-plugin/blob/master/python/rpdk/java/templates/init/guided_aws/ResourceModel.java#L20

One of the reasons I would like to see this flag enabled is a significant simplification of overriding massive resource model definitions in testing, especially in testing an UpdateHandler.

Here is an example:

public class AbstractTestBase {
  protected static final ResourceModel MODEL_BEFORE;
  protected static final ResourceModel MODEL_AFTER;

  static {
    MODEL_BEFORE = ResourceModel.builder()
      .foo("foo-before")
      .bar("bar-before")
      .baz("baz-before")
      .build();
    MODEL_AFTER = ResourceModel.builder()
      .foo("foo-before")
      .bar("bar-before")
      .baz("totally-different-baz")
      .build();
  }
}

Assume I'm using these models in UpdateHandler test suite. If the update flow has a broad branching based on model attribute invariants, one has to initiate separate model instances for each branch case. It's completely fine for a 5-10 attribute models, but the burden of carrying things around grows once one has to deal with a 30-50 attribute model.

Having toBuilder = true enabled in ResourceModel definition would let one define models like

public class AbstractTestBase {
  protected static final ResourceModel MODEL_BEFORE;
  protected static final ResourceModel MODEL_AFTER;

  static {
    MODEL_BEFORE = ResourceModel.builder()
      .foo("foo-before")
      .bar("bar-before")
      .baz("baz-before")
      .build();
    MODEL_AFTER = MODEL_BEFORE.toBuilder()
      .baz("totally-different-baz")
      .build();
  }
}

In fact, being able to override a static model locally within the current test case scope is even better, it could look like:

public class UpdateHandlerTest extends AbstractTestBase {
  //...
  public void handleRequest_SimpleSuccess() {
    final ResourceModel modelWithUpdatedBaz = MODEL_BEFORE.toBuilder()
      .baz("totally-different-baz")
      .build();
      //...
  }
}
主要语言
Java
星标
30
派生
48
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

aws-cloudformation/cloudformation-cli-java-plugin 的其他 Issue

查看 aws-cloudformation/cloudformation-cli-java-plugin 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。