Skip to content

@FunctionalInterface on functional interfaces #3

@tomwhoiscontrary

Description

@tomwhoiscontrary

Jetlang contains a few widely-used interfaces which contain a single abstract method with no method-level type parameters. These are therefore "functional interfaces", and can be implemented with lambda expressions and method references. The primary example would be Publisher, but Filter, Callback, and Converter are others. In my code, all of these are often implemented by lambdas and method references, probably even a majority of the time.

Java has an annotation, @FunctionalInterface, to mark functional interfaces. It's purely a marker annotation, and has no functional consequences, so these interfaces are just as usable without it as with it.

With one substantial exception: IntelliJ will only consider an interface as the target of an Extract Functional Parameter or Extract Functional Variable refactoring if it is annotated with @FunctionalInterface! I lean very heavily on IntelliJ's refactorings, including that one, and when i'm doing Jetlang plumbing, it's a definite drag not to be able to quickly extract something into a Publisher or whatever.

So, could we add @FunctionalInterface to functional interfaces where possible?

I'm happy to submit a PR to that if so.

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