GeezerVison is showing github.com — [java] Lombok: support `@Builder` on types by Pankraz76 · Pull Request #7241 · pmd/pmd
Conversation
Pankraz76
commented
Oct 26, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Describe the PR
Adds symbols for what Lombok's @Builder generates when it is placed on a class:
- the nested builder class, with one setter-like method per field and the build method
- the static
builder() method and, with toBuilder = true, the toBuilder() instance method
The attributes builderClassName, builderMethodName, buildMethodName, setterPrefix, toBuilder and access are honored, as is @Builder.Default. If the class already declares the builder class by hand, only the missing methods are added to it.
Not supported yet: generic classes, @Singular, @Builder on constructors or methods, and @SuperBuilder.
Related issues
Ready?
- Added unit tests for fixed bug/feature
- Passing all unit tests
- Complete build
./mvnw clean verify passes (checked automatically by github actions)
- Added (in-code) documentation (if needed)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Creates the builder class, its setter-like methods and build method,
the static builder() method and toBuilder(). Honors builderClassName,
builderMethodName, buildMethodName, setterPrefix, toBuilder, access and
@Builder.Default, and completes handwritten builder classes.
Not supported: generic classes, @Singular, @builder on constructors
or methods, and @SuperBuilder.
Refs pmd#3119
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PPz9uxrZpT8ysmD5A2Fgg5
Pankraz76
changed the title
[java] Lombok: support @Builder on types
[java] Lombok: support @Builder on types
Oct 26, 2026
|
Documentation Preview
Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
There are 0 changed duplications, 0 new duplications and 0 removed duplications.
There are 0 changed CPD errors, 0 new CPD errors and 0 removed CPD errors.
Regression Tester Report
(comment created at 2026-11-13 17:05:29+00:00 for 96146eb)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks for creating the PR. Please ask Claude to compare your PR to the earlier PR #7198 (already merged) and update this PR if there are any differences left.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Resolve the conflicts with pmd#7198, which added the (empty) builder class
of lombok.Builder. Build on that implementation instead of duplicating it:
- keep the builder class of pmd#7198, including builders of constructors
and methods, the '*' wildcard of builderClassName and the annotation scope
- add the members for @builder on a non-generic class: the methods of the
builder class, builder() and toBuilder()
- honor the access attribute for the builder class
- a handwritten builder class gets the methods it does not declare
Builders of generic classes, constructors and methods stay empty classes.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MTr23wWTVcrESgpWPAS9iR
|
Thanks for the pointer. I asked Claude to compare this PR with #7198 and merged main:
- Redundant, removed here: creating the builder class and resolving
builderClassName. This PR now reuses the class from [java] Fix #6731: Support lombok.Builder (fix UnnecessaryFullyQualifiedName false positive) #7198, including constructor/method builders, the * wildcard and the annotation scope.
- Remaining delta: for
@Builder on a non-generic class, the builder's methods (one per field plus build()), builder() and toBuilder(), honouring access, setterPrefix, builderMethodName, buildMethodName and @Builder.Default. A handwritten builder class gets the methods it does not declare.
- Still unsupported: members for generic classes and for constructor/method builders,
@Singular, @SuperBuilder.
Two behaviour changes against main: access now sets the visibility of every generated builder class, and access = AccessLevel.NONE generates nothing.
All tests from #7198 still pass; the full pmd-java suite and checkstyle are green locally.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This branch has not been deployed
No deployments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|