Class EnumValueNameCheck

  • All Implemented Interfaces:
    com.puppycrawl.tools.checkstyle.api.Configurable, com.puppycrawl.tools.checkstyle.api.Contextualizable

    public class EnumValueNameCheck
    extends com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck

    Checks that enumeration value names conform to a format specified by the format property. The format is a regular expression and defaults to ^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$.

    An example of how to configure the check is:

     <module name="EnumValueName"/>
     

    An example of how to configure the check for names that requires all names to be lowercase with underscores and digits is:

     <module name="EnumValueName">
        <property name="format" value="^[a-z_0-9]+*$"/>
     </module>
     
    Since:
    1.24.0
    Author:
    Pavel Baranchikov
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean

        com.puppycrawl.tools.checkstyle.api.AutomaticBean.OutputStreamOptions
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String DEFAULT_PATTERN
      Default pattern for Values Enumeration names.
      • Fields inherited from class com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck

        MSG_INVALID_PATTERN
    • Constructor Summary

      Constructors 
      Constructor Description
      EnumValueNameCheck()
      Creates a new EnumValueNameCheck instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int[] getAcceptableTokens()  
      int[] getDefaultTokens()  
      int[] getRequiredTokens()  
      protected boolean mustCheckName​(com.puppycrawl.tools.checkstyle.api.DetailAST ast)  
      • Methods inherited from class com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck

        setFormat, visitToken
      • Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck

        beginTree, clearViolations, destroy, finishTree, getFileContents, getFilePath, getLine, getLineCodePoints, getLines, getTabWidth, getTokenNames, getViolations, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokens
      • Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter

        finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
      • Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean

        configure, contextualize, getConfiguration, setupChild
    • Field Detail

      • DEFAULT_PATTERN

        public static final String DEFAULT_PATTERN
        Default pattern for Values Enumeration names.
        See Also:
        Constant Field Values
    • Constructor Detail

      • EnumValueNameCheck

        public EnumValueNameCheck()
        Creates a new EnumValueNameCheck instance.
    • Method Detail

      • getDefaultTokens

        public int[] getDefaultTokens()
        Specified by:
        getDefaultTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheck
      • getAcceptableTokens

        public int[] getAcceptableTokens()
        Specified by:
        getAcceptableTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheck
      • getRequiredTokens

        public int[] getRequiredTokens()
        Specified by:
        getRequiredTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheck
      • mustCheckName

        protected boolean mustCheckName​(com.puppycrawl.tools.checkstyle.api.DetailAST ast)
        Specified by:
        mustCheckName in class com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck