Class InterfaceTypeParameterNameCheck

  • All Implemented Interfaces:
    Configurable, Contextualizable

    public class InterfaceTypeParameterNameCheck
    extends AbstractNameCheck

    Checks that interface type parameter names conform to a specified pattern.

    • Property format - Specifies valid identifiers. Type is java.util.regex.Pattern. Default value is "^[A-Z]$".

    To configure the check:

     <module name="InterfaceTypeParameterName"/>
     

    Code Example:

     interface FirstInterface<T> {} // OK
     interface SecondInterface<t> {} // violation, name 't' must match pattern '^[A-Z]$'
     

    An example of how to configure the check for names that are only a single letter is:

     <module name="InterfaceTypeParameterName">
        <property name="format" value="^[a-zA-Z]$"/>
     </module>
     

    Code Example:

     interface FirstInterface<T> {} // OK
     interface SecondInterface<t> {} // OK
     interface ThirdInterface<type> {} // violation, name 'type' must
                                             // match pattern '^[a-zA-Z]$'
     

    Parent is com.puppycrawl.tools.checkstyle.TreeWalker

    Violation Message Keys:

    • name.invalidPattern
    Since:
    5.8