Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add FunctionalInterface annotation #1515

Merged
merged 7 commits into from
Apr 11, 2023
Merged

Conversation

JoeWang1127
Copy link
Collaborator

@JoeWang1127 JoeWang1127 commented Mar 21, 2023

Fixes #1516 ☕️

@product-auto-label product-auto-label bot added the size: s Pull request size is small. label Mar 21, 2023
@JoeWang1127 JoeWang1127 marked this pull request as ready for review March 21, 2023 14:31
@JoeWang1127 JoeWang1127 requested a review from a team as a code owner March 21, 2023 14:31
@@ -34,6 +34,7 @@

/** Interface for functionality to enhance headers for an http-json call. */
@BetaApi
@FunctionalInterface
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would not add FunctionalInterface to anything that is marked as BetaApi. Especially for things in httpjson folder.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is this because BetaApi is not stable?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done.

@@ -94,6 +94,7 @@ public Iterator<CollectionT> iterator() {
};
}

@FunctionalInterface
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think adding FunctionalInterface to a private interface has value, as we are free to change them at any time.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done.

@@ -51,6 +51,7 @@
*/
@BetaApi
public class MtlsProvider {
@FunctionalInterface
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as the above private one, I don't think adding FunctionalInterface to a non-public interface has value, this interface should probably be marked as private in the first place also.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed the annotation.

I'll leave the interface as public since changing it to private is out of scope of this PR.

@@ -39,6 +39,7 @@
*/
public class ValidationException extends IllegalArgumentException {

@FunctionalInterface
Copy link
Collaborator

@blakeli0 blakeli0 Mar 28, 2023

Choose a reason for hiding this comment

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

This and above inner-public interface are so weird, probably because we wanted to mimic the same behavior of java.util.function.Supplier in Java 7. That being said, I think adding FunctionalInterface to them are appropriate because they are exposed on the surface through other public methods. But we may want to consider replacing these Supplier with java.util.function.Supplier as part of the Java 8 adoption project. CC: @suztomo

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the comments.

I'll do a research on replacing Supplier with java.util.function.Supplier. Leave it as-is as this is out of scope of this PR.

Copy link
Member

@burkedavison burkedavison Mar 29, 2023

Choose a reason for hiding this comment

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

It would break binary compatibility, and so we'd need a major rev bump.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It would break binary compatibility, and so we'd need a major rev bump.

Are you referring to the idea of replacing Supplier with java.util.function.Supplier? I think it depends on how we approach it, if we do it naively yes it would be a breaking change. We could approach it in steps like adding alternatives first, replacing the ones that are not on the surface first etc.

@@ -35,6 +35,7 @@
/** Provider of custom REST ClientInterceptors. */
@BetaApi(
"The surface for adding custom interceptors is not stable yet and may change in the future.")
@FunctionalInterface
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you remove this as well since it's beta?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -29,6 +29,7 @@
*/
package com.google.api.gax.batching;

@FunctionalInterface
public interface BatchMerger<B> {
void merge(B batch, B newBatch);
Copy link
Member

Choose a reason for hiding this comment

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

In future, if we would add void merge(List<B>);, then this shouldn't be a functional interface.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The interface is called BatchMerger, it's weird to merge a list.

@sonarcloud
Copy link

sonarcloud bot commented Apr 3, 2023

[gapic-generator-java-root] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@sonarcloud
Copy link

sonarcloud bot commented Apr 3, 2023

[java_showcase_integration_tests] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

}
},
context);
internalCall(bidiObserver, bidiObserver, context);
Copy link
Member

Choose a reason for hiding this comment

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

Nice.

@sonarcloud
Copy link

sonarcloud bot commented Apr 3, 2023

[java_showcase_unit_tests] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@suztomo
Copy link
Member

suztomo commented Apr 3, 2023

Let's wait to schedule changes together.

Also get a review from Ben, who requested this.

@suztomo suztomo added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Apr 3, 2023
@suztomo suztomo removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Apr 11, 2023
@JoeWang1127 JoeWang1127 merged commit 66c0509 into main Apr 11, 2023
@JoeWang1127 JoeWang1127 deleted the feat/add-annotation branch April 11, 2023 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add FunctionalInterface to appropriate interfaces
5 participants