Annotate functional interfaces
Occasionally, when you can't find what you need among the JDK's
standard functional interfaces,
then you'll need to define your own functional interface.
When you do so, you should annotate it with
@FunctionalInterface
.
Using @FunctionalInterface
will:
- express your intent clearly
- communicate that the interface was designed for functional programming
- prevent maintainers from mistakenly adding abstract methods (a functional interface,
by definition, has only one abstract method)
See Also :