Class GenericClassCounterRule

  • All Implemented Interfaces:
    JavaParserVisitor, ImmutableLanguage, PropertySource, Rule

    public class GenericClassCounterRule
    extends AbstractJavaRule

    A generic rule that can be configured to "count" classes of certain type based on either their name (full name, prefix, suffixes anything can be matched with a regex), and/or their type.

    Example of configurations:

         <!-- Property order is MANDATORY !!! -->
         <!-- Several regexes may be provided to ensure a match... -->
         <property name="nameMatch" description="a regex on which to match"
             value="^Abstract.*Bean*$,^*EJB*$"/>
         <!-- An operand to refine match strategy TODO: Not implemented yet !!! -->
         <property name"operand" description=""
             value="and"/> <!-- possible values are and/or -->
         <!-- Must be a full name to ensure type control !!! -->
         <property name="typeMatch" description="a regex to match on implements/extends classname"
             value="javax.servlet.Filter"/>
         <!-- Define after how many occurrences one should log a violation -->
         <property name="threshold" description="Defines how many occurrences are legal"
             value="2"/>
         <!-- TODO: Add a parameter to allow "ignore" pattern based on name -->
     
    Author:
    Ryan Gutafson, rgustav@users.sourceforge.net, Romain PELISSE, belaran@gmail.com