Skip to content

Accept any annotation with the simple name @Generated - #2125

Merged
copybara-service[bot] merged 1 commit into
masterfrom
test_352461144
Jan 19, 2021
Merged

copybara-service[bot] merged 1 commit into
masterfrom
test_352461144

Conversation

@copybara-service

Copy link
Copy Markdown
Contributor

Accept any annotation with the simple name @Generated

to support non-standard annotations.

Fixes #1984, #1863

@google-cla google-cla Bot added the cla: yes label Jan 19, 2021
to support non-standard annotations.

Fixes #1984, #1863

PiperOrigin-RevId: 352622403
@copybara-service
copybara-service Bot merged commit 4d6a0cc into master Jan 19, 2021
@copybara-service
copybara-service Bot deleted the test_352461144 branch January 19, 2021 20:04
Comment on lines +1376 to +1378
.map(e -> MoreAnnotations.asStrings((AnnotationValue) e.getValue()))
.findAny()
.orElse(Stream.of(attribute.type.tsym.getQualifiedName().toString()));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Late to the party, but would suggest:

Suggested change
.map(e -> MoreAnnotations.asStrings((AnnotationValue) e.getValue()))
.findAny()
.orElse(Stream.of(attribute.type.tsym.getQualifiedName().toString()));
.findFirst()
.map(e -> MoreAnnotations.asStrings((AnnotationValue) e.getValue()))
.orElseGet(() -> Stream.of(attribute.type.tsym.getQualifiedName().toString()));
  • .firstFirst just because that's what happens in practice in this non-parallel stream, and is thus arguably clearer than .findAny.
  • .map after .findFirst to clarify that only one map operation will be performed.
  • .orElseGet rather than .orElse for efficiency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ignore when annotated with @Generated

2 participants