Feature: propagate @Deprecated (and its javadoc) from the DTO to the generated builder
Problem
When a DTO, one of its setters, a field or a constructor parameter is marked @Deprecated, that information is currently (almost entirely) lost in the generated builder. A user of the builder gets no IDE strikethrough and no compiler warning, so it is invisible that the value should not be used anymore. The explanatory @deprecated javadoc text is not carried over either.
Current behavior
- Only parameter-level / type-use annotations are extracted (
FieldAnnotationExtractor.extractAnnotations(VariableElement, …), called from BuilderDefinitionCreator.createFieldDto), and they are applied to the parameter of the generated setter method:
public ServiceBuilder name(@Deprecated String name) { … }
(covered by AnnotationCopyTest.annotations_deprecatedCopied_suppressWarningsFiltered)
- Nothing is read from the setter method element, the backing field, or the DTO type element — so
@Deprecated on a setter, on a field, on a record component or on the DTO class itself does not reach the builder at all.
- Only the
@param text of the setter/constructor javadoc is extracted (JavaLangAnalyser.extractParamJavaDoc); the @deprecated javadoc tag is never picked up.
Expected behavior
- Deprecated field / setter / constructor parameter → every generated builder method for that field (basic setter, supplier, consumer, collection helpers, varargs,
with…, …) is annotated with @Deprecated on the method itself, not just on the parameter.
- Deprecated DTO type → the generated builder class (and its factory methods) is annotated
@Deprecated.
- Javadoc → the original
@deprecated <text> javadoc tag is copied into the javadoc of the generated builder members, so the migration hint stays visible. If no explicit text exists, the member is still marked deprecated (annotation only).
- Detection should consider
@Deprecated on all relevant elements of a property: constructor parameter, record component, backing field, setter method, and getter method.
- The generated builder itself must still compile without deprecation warnings where it legitimately calls the deprecated setter/constructor of the DTO (e.g. suppress inside
build()), so users only see warnings for their own usage.
Notes / open points
@Deprecated(since = "…", forRemoval = true) attributes should be preserved.
- Deprecating the whole builder class when the DTO is deprecated may be worth an explicit decision (could be noisy) — but it matches the "the DTO should not be used anymore" intent.
- Should be covered by compile-testing cases in
AnnotationCopyTest for: deprecated setter, deprecated field, deprecated record component, deprecated DTO class, and @deprecated javadoc text propagation.
Original request (DE)
Deprecated Annotationen an DTOs oder Settern oder Constructor-Parametern sollten auch Builder mit übernommen werden. Ansonsten ist bei Verwendung des Builders nicht sichtbar, dass diese eigentlich nicht mehr verwendet werden sollten. Ferner sollte dann auch der Javadoc-Eintrag übernommen werden.
Feature: propagate
@Deprecated(and its javadoc) from the DTO to the generated builderProblem
When a DTO, one of its setters, a field or a constructor parameter is marked
@Deprecated, that information is currently (almost entirely) lost in the generated builder. A user of the builder gets no IDE strikethrough and no compiler warning, so it is invisible that the value should not be used anymore. The explanatory@deprecatedjavadoc text is not carried over either.Current behavior
FieldAnnotationExtractor.extractAnnotations(VariableElement, …), called fromBuilderDefinitionCreator.createFieldDto), and they are applied to the parameter of the generated setter method:AnnotationCopyTest.annotations_deprecatedCopied_suppressWarningsFiltered)@Deprecatedon a setter, on a field, on a record component or on the DTO class itself does not reach the builder at all.@paramtext of the setter/constructor javadoc is extracted (JavaLangAnalyser.extractParamJavaDoc); the@deprecatedjavadoc tag is never picked up.Expected behavior
with…, …) is annotated with@Deprecatedon the method itself, not just on the parameter.@Deprecated.@deprecated <text>javadoc tag is copied into the javadoc of the generated builder members, so the migration hint stays visible. If no explicit text exists, the member is still marked deprecated (annotation only).@Deprecatedon all relevant elements of a property: constructor parameter, record component, backing field, setter method, and getter method.build()), so users only see warnings for their own usage.Notes / open points
@Deprecated(since = "…", forRemoval = true)attributes should be preserved.AnnotationCopyTestfor: deprecated setter, deprecated field, deprecated record component, deprecated DTO class, and@deprecatedjavadoc text propagation.Original request (DE)