Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,16 @@
*/
String beanClassName() default "";

/**
* When to add the {@link javax.annotation.processing.Generated} annotation to generated files
*
* <p>
* If set to 'ALWAYS' (default), then always add the {@link javax.annotation.processing.Generated} annotation to
* generated files.
* </p>
*/
GeneratedAnnotation addGeneratedAnnotation() default GeneratedAnnotation.ALWAYS;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use a boolean here instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, not giving a choice for later options, like IF_ON_CLASSPATH or USE_USER_SUPPLIED_ANNOTATION? Just want to check. Booleans are restrictive, no choice of extending the options later on!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have an option for "if on classpath" (that should be respected, BTW) so that ship has already sailed. Also, the use of the enum is very cumbersome. Let's use a boolean please.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen such an option. How can I enabled the "Generated" annotation already? It's not on the classpath and it got generated.
If we could make that working, let's just drop by this PR and issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Randgalt I have looked for this option but did not find it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@bmarwell bmarwell Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Randgalt that is about the RecordBuilderGenerated which does not need more than 2 states (add, do not add).
The issue is different with @Generated, because we could have it added conditionally. Because of this, I still recommend going with the ENUM approach.


/**
* If true, generated classes are annotated with {@code RecordBuilderGenerated} which has a retention policy of
* {@code CLASS}. This ensures that analyzers such as Jacoco will ignore the generated class.
Expand Down Expand Up @@ -378,6 +388,18 @@ enum ConcreteSettersForOptionalMode {
DISABLED, ENABLED, ENABLED_WITH_NULLABLE_ANNOTATION,
}

enum GeneratedAnnotation {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use this enum I'd like to think of better names. ALWAYS and NEVER are limiting. We will have trouble add another values that works with these. Some alternatives:

  • ENABLED / DISABLED
  • INCLUDE / EXCLUDE

Also, we could name the method generatedAnnotationMode or something similar.

/**
* Always add the {@link javax.annotation.processing.Generated} annotation (default).
*/
ALWAYS,
/**
* Never add the {@link javax.annotation.processing.Generated} annotation.
*/
NEVER,
/* IF_ON_CLASSPATH, */ /* USER_SUPPLIED, */
}

/**
* Apply to record components to specify a field initializer for the generated builder
*/
Expand Down
Loading