Class ImplicitFunctionalInterfaceRule

java.lang.Object
net.sourceforge.pmd.properties.AbstractPropertySource
net.sourceforge.pmd.lang.rule.AbstractRule
net.sourceforge.pmd.lang.java.rule.AbstractJavaRule
net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule
com.qulice.pmd.rules.ImplicitFunctionalInterfaceRule
All Implemented Interfaces:
net.sourceforge.pmd.lang.ast.AstVisitor, net.sourceforge.pmd.lang.java.ast.JavaVisitor, net.sourceforge.pmd.lang.rule.Rule, net.sourceforge.pmd.properties.PropertySource

public final class ImplicitFunctionalInterfaceRule extends net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule
Rule to flag an interface that is implicitly functional (declares exactly one abstract method) but is not annotated with @FunctionalInterface.

Unlike PMD's built-in ImplicitFunctionalInterface rule, this variant refuses to fire when the interface extends a super-interface whose type PMD cannot resolve. The built-in rule counts only the abstract methods it can see: when a super-interface is unresolved (for instance because Qulice runs PMD without an auxiliary classpath, so types declared in other files are invisible), the rule misses the abstract methods that super-interface contributes and wrongly reports the interface as functional. Adding the suggested @FunctionalInterface annotation to such an interface does not compile, because the interface really has more than one abstract method. An interface with a single visible method whose full set of inherited abstract methods cannot be computed is therefore left alone. Once the whole super-interface hierarchy resolves, the check is exactly the same as the built-in one: fire only when the interface has a single abstract method overall.

Since:
1.0
  • Field Summary

    Fields inherited from interface net.sourceforge.pmd.lang.rule.Rule

    VIOLATION_SUPPRESS_REGEX_DESCRIPTOR, VIOLATION_SUPPRESS_XPATH_DESCRIPTOR
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    visit(net.sourceforge.pmd.lang.java.ast.ASTClassDeclaration node, Object data)
     

    Methods inherited from class net.sourceforge.pmd.lang.java.rule.AbstractJavaRulechainRule

    buildTargetSelector, visitJavaNode

    Methods inherited from class net.sourceforge.pmd.lang.java.rule.AbstractJavaRule

    apply, visitNode

    Methods inherited from class net.sourceforge.pmd.lang.rule.AbstractRule

    addExample, asCtx, deepCopy, dysfunctionReason, end, equals, getDescription, getExamples, getExternalInfoUrl, getLanguage, getMaximumLanguageVersion, getMessage, getMinimumLanguageVersion, getName, getPriority, getPropertySourceType, getRuleClass, getRuleSetName, getSince, getTargetSelector, hashCode, isDeprecated, setDeprecated, setDescription, setExternalInfoUrl, setLanguage, setMaximumLanguageVersion, setMessage, setMinimumLanguageVersion, setName, setPriority, setRuleClass, setRuleSetName, setSince, start

    Methods inherited from class net.sourceforge.pmd.properties.AbstractPropertySource

    definePropertyDescriptor, getOverriddenPropertiesByPropertyDescriptor, getOverriddenPropertyDescriptors, getPropertiesByPropertyDescriptor, getProperty, getPropertyDescriptor, getPropertyDescriptors, hasDescriptor, isPropertyOverridden, setProperty

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.sourceforge.pmd.lang.ast.AstVisitor

    cannotVisit

    Methods inherited from interface net.sourceforge.pmd.lang.java.ast.JavaVisitor

    visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit

    Methods inherited from interface net.sourceforge.pmd.properties.PropertySource

    definePropertyDescriptor, getOverriddenPropertiesByPropertyDescriptor, getOverriddenPropertyDescriptors, getPropertiesByPropertyDescriptor, getProperty, getPropertyDescriptor, getPropertyDescriptors, hasDescriptor, isPropertyOverridden, setProperty

    Methods inherited from interface net.sourceforge.pmd.lang.rule.Rule

    initialize
  • Constructor Details

    • ImplicitFunctionalInterfaceRule

      public ImplicitFunctionalInterfaceRule()
      Default constructor.
  • Method Details

    • visit

      public Object visit(net.sourceforge.pmd.lang.java.ast.ASTClassDeclaration node, Object data)