Skip to content

Documentation/Javadoc implies @SimpleBuilder is inherited, but it is not #244

Description

@AndreasIgel

Summary

@SimpleBuilder is not meta-annotated with java.lang.annotation.Inherited, and BuilderProcessor collects types via RoundEnvironment.getElementsAnnotatedWith(...), which only returns inherited annotations when the annotation type itself is @Inherited.

I verified this with temporary sanity tests:

  • A parent with plain @SimpleBuilder and an unannotated child class does not produce a builder for the child.
  • A custom annotation meta-annotated with @SimpleBuilder.Template and @Inherited, placed on a parent, does produce a builder for an unannotated child.

So in practice only @SimpleBuilder.Template (via custom annotations that themselves are @Inherited) is inherited, not the plain @SimpleBuilder annotation.

Places that currently imply @SimpleBuilder is inherited

  • core/src/main/java/org/javahelpers/simple/builders/core/annotations/SimpleBuilder.java class-level Javadoc: "when an inherited @SimpleBuilder or @SimpleBuilder.Template would otherwise trigger it"
  • docs/CONFIGURATION.md (## Excluding Types from Builder Generation): "when a class inherits @SimpleBuilder or an @SimpleBuilder.Template annotation from a parent" and "even if ParentDto carries @SimpleBuilder or an @Inherited template annotation"
  • Ignore4BuilderGeneration.java Javadoc: "even if @SimpleBuilder or @SimpleBuilder.Template annotation is inherited from a parent type"

Suggested fix

SimpleBuilder should get inherited too and the documentation should be checked and possibly updated regarding inheritance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions