EnumValueName check #168

Closed
romani opened this Issue Feb 19, 2014 · 2 comments

Projects

None yet

2 participants

@romani
Member
romani commented Feb 19, 2014

Check forces enum values to match the specific pattern. According to "Java Coding Style" by Achut Reddy p 3.3 constants include "all static final object reference types that are never followed by " ." (dot).", i.e. enums, which are followed by dot while used in the code are to be treated as static object references, while enums, that are not used with following dot, should be treated as constants.
Enums are defined to be used as class have some own methods. This condition is used to distinguish between Values Enumeration and Class Enumeration. Values Enumeration looks like the following:

enum SimpleErrorEnum
  {
      FIRST_SIMPLE, SECOND_SIMPLE, THIRD_SIMPLE;
  }

While Class Enumeration has some methods, for example:

 enum SimpleErrorEnum
   {
       FIRST_SIMPLE, SECOND_SIMPLE, THIRD_SIMPLE;

       public String toString() {
           return Integer.toString(ordinal() + 10);
       }
   }

Name format for Class Enumeration is specified with setObjFormat(String) , while format for enum constants - with setConstFormat(String)
To avoid assuming enum as static object reference, while using some specific methods, setExcludes(List) can be used. For example to make enum in the previous example a constant set Excludes property to a value toString
By default toString is used as an exclusion.

@pbaranchikov pbaranchikov was assigned by romani Feb 19, 2014
@romani
Member
romani commented Apr 25, 2014

fixed by @pbaranchikov.

@romani romani closed this Apr 25, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment