Skip to content

Builders for codegen model DTOs (GenerationTargetClassDto & friends) #415

Description

@igel-devin-ai

Motivation

Tests (and API consumers) construct the codegen model DTOs field-by-field via setters, which makes test code verbose — e.g. RoasterCodeGeneratorTest builds a GenerationTargetClassDto through ~10 setter calls per case. A fluent builder per DTO would shrink this considerably and double as a nicer public API surface for anyone driving the generator programmatically.

Scope — codegen-core model DTOs (public API)

These are the DTOs an API user assembles to call the generator, ordered by payoff:

  • GenerationTargetClassDto — the root target, biggest test-code win
  • ClassFieldDto
  • MethodDto, MethodParameterDto, MethodCodeDto, ConstructorDto, CodeTemplateDto
  • AnnotationDto
  • JavadocDto, JavadocCodeBlockDto
  • NestedTypeDto, GenericParameterDto

Scope — processor-internal DTOs

BuilderDefinitionDto, BuilderFieldDto, BuilderMethodDto, BuilderNestedTypeDto are processor-internal rather than API surface — builders would still slim down tests; lower priority, could be a second step.

Notes

  • Builder style could follow the generated builders this project itself produces (X.builder().field(v)...build()), or reuse the project's own annotation processor to generate them.
  • Alternatively the DTOs could become records with canonical constructors — bigger refactor, changes all consumers.

Spawned from #401 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions