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

Annotate Java facade listener interfaces as functional #173

Open
QuintinWillison opened this issue Feb 9, 2021 · 3 comments
Open

Annotate Java facade listener interfaces as functional #173

QuintinWillison opened this issue Feb 9, 2021 · 3 comments
Labels
breaking Backwards incompatible changes made to the public API. enhancement New feature or improved functionality.

Comments

@QuintinWillison
Copy link
Contributor

QuintinWillison commented Feb 9, 2021

See https://www.baeldung.com/java-8-lambda-expressions-tips#functionalInterface for reasons behind this being a good idea / best practice.

@KacperKluka
Copy link
Contributor

@QuintinWillison I've checked and the @FunctionalInterface annotation only works in .java files. If it's used in a .kt file it has no effect at all and you can declare multiple methods in the annotated interface without any errors.
So if we'd really like to use that annotation then we would have to refactor those interfaces from Kotlin to Java. WDYT?

@QuintinWillison
Copy link
Contributor Author

Thanks for checking. That is interesting. Refactoring these interfaces to Java is probably a very good idea. I can't imagine there are any Kotlin features that the facade projects (for publishing and subscribing) are using that would stop us doing this, but that would clearly fall out when it comes to carrying out this task.

@QuintinWillison
Copy link
Contributor Author

Relates to #174, in that we could present the Java facade interfaces as a Java project and then implement them in Kotlin via a second project.

i.e., ideally, we would keep the existing Kotlin projects subscribing-sdk-java and publishing-sdk-java as facade implementations, and add new Java projects subscribing-sdk-java-api and publishing-sdk-java-api which would be pure interface declarations, leveraging @FunctionalInterface annotation where appropriate.

@QuintinWillison QuintinWillison added enhancement New feature or improved functionality. breaking Backwards incompatible changes made to the public API. and removed api labels Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Backwards incompatible changes made to the public API. enhancement New feature or improved functionality.
Development

No branches or pull requests

2 participants