Skip to content

feat: model and render fields and constructors in nested types (#487) - #488

Merged
AndreasIgel merged 3 commits into
java-helpers:mainfrom
igel-devin-ai:issue-487-nested-type-members
Dec 5, 2026
Merged

AndreasIgel merged 3 commits into
java-helpers:mainfrom
igel-devin-ai:issue-487-nested-type-members

Conversation

@igel-devin-ai

Copy link
Copy Markdown
Contributor

Summary

Implements #487: NestedTypeDto can now carry fields and constructors, and Roaster renders them.

  • Model: NestedTypeDto gains classFields and constructors lists with getters/adders, mirroring what GenerationTargetClassDto already models
  • Builder: NestedTypeDtoBuilder gains the full helper set for both (element-adds, single/plural consumers, wholesale replacement), consistent with the existing collection conventions
  • Rendering: Roaster renders fields and constructors for nested classes. Nested interfaces skip both: Java interfaces cannot declare constructors, and their fields are implicitly constants — Roaster does not support fields on interface sources at all

Notes

Tests

  • RoasterCodeGeneratorTest: nested class renders field + constructor; nested interface renders neither
  • NestedTypeDtoBuilderTest: consumer/varargs/copy coverage for the new helpers (5 new tests)

…helpers#487)

- NestedTypeDto gains classFields and constructors, with the full
  builder helper set on NestedTypeDtoBuilder (element-adds, consumers,
  varargs consumers, wholesale replacement)
- Roaster renders fields and constructors for nested classes; nested
  interfaces skip both since Java interfaces cannot declare constructors
  and their fields are implicitly constants
- tests: rendering of nested fields/constructors, interface exclusion,
  builder helper coverage
this.methods.add(method);
}

public List<ClassFieldDto> getClassFields() {
this.classFields.add(classField);
}

public List<ConstructorDto> getConstructors() {
devin-ai-integration Bot added a commit to igel-devin-ai/simple-builders-devin-fork that referenced this pull request Dec 4, 2026
- nested-type validation now recurses into fields and constructors,
  not just methods (model support added in java-helpers#487/java-helpers#488)
- nested interfaces declaring constructors or fields are rejected:
  constructors are impossible in interfaces, fields are implicit
  constants and cannot be generated as declared
@codecov

codecov Bot commented Dec 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@sonarqubecloud

sonarqubecloud Bot commented Dec 5, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@AndreasIgel
AndreasIgel merged commit 4da4a8f into java-helpers:main Dec 5, 2026
6 checks passed
devin-ai-integration Bot added a commit to igel-devin-ai/simple-builders-devin-fork that referenced this pull request Dec 5, 2026
- nested-type validation now recurses into fields and constructors,
  not just methods (model support added in java-helpers#487/java-helpers#488)
- nested interfaces declaring constructors or fields are rejected:
  constructors are impossible in interfaces, fields are implicit
  constants and cannot be generated as declared
AndreasIgel pushed a commit that referenced this pull request Dec 5, 2026
* feat: validate generation targets before rendering (#465)

Extends and moves GenerationTargetValidator into codegen-core
(org.javahelpers.codegen.validation): duplicate parameter names,
duplicate method/constructor signatures (erasure-aware via
JavaSignatures), duplicate field names, nested-type collisions,
simple-name collisions of referenced types, reserved words and
illegal identifiers. Collects all violations into one exception.

Stacked on java-signature-erasure: the signature calculation is
split into its own PR.

* fix: validate static import collisions and reuse field validation

- validateFields takes the field list so it can be reused for nested
  type validation
- static imports are checked for member-name collisions across
  different owners

* feat: validate nested-type members and interface-kind restrictions

- nested-type validation now recurses into fields and constructors,
  not just methods (model support added in #487/#488)
- nested interfaces declaring constructors or fields are rejected:
  constructors are impossible in interfaces, fields are implicit
  constants and cannot be generated as declared

* refactor: validate on instance state instead of threaded parameters

The static entry point now creates a validator instance holding the
collected violations, the validation context and the type-variable
bounds, so the private validation methods no longer repeat targetName
and violations in every signature. Nested-type recursion scopes context
and type-variable bounds with save/restore.

---------

Co-authored-by: Andreas Igel <Andreas.Igel@gmx.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants