Why should a single method interface be tagged @FunctionalInterface?

717 views Asked by At

SonarQube gives me a bunch of Squid:S1909 @FunctionalInterface annotation should be used to flag Single Abstract Method interface warnings.

The explanation is not too great. It mentions breaking existing lamda expressions, but wouldn't the compiler already catch if I add a new method to the interface and break existing lambdas? Is the annotation mainly about intention revealing here?

If the code is not used in lambda expressions (it isn't because it's from a legacy code base where only some interfaces are used in lambdas) --- is there any point in adding @FunctionalInterface?

0

There are 0 answers