// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/ClassUtils.java
// public static final String ABSTRACT_CLASS_PREFIX = "Abstract";
// 
// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/ClassUtils.java
// public static String getClassName(DetailAST classAst) {
//   DetailAST type = classAst.findFirstToken(TokenTypes.LITERAL_CLASS);
//   return type.getNextSibling().getText();
// }
// 
// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/ClassUtils.java
// public static Boolean isEntity(DetailAST classAst, String fullEntityAnnotation) {
//   return AnnotationUtils.hasAnnotation(classAst, fullEntityAnnotation);
// }
// 
// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/CommonUtils.java
// public static String getNameWithoutContext(String name, String contextName) {
//   String suggestedName = "";
//   String[] separated = name.split("(?i)" + contextName);
//   for (String separatedName : separated) {
//     if (!isEmpty(separatedName)) {
//       suggestedName = suggestedName + separatedName;
//     }
//   }
//   return isEmpty(suggestedName) ? name :
//       suggestedName.substring(0, 1).toLowerCase() + suggestedName.substring(1);
// }
// 
// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/VariableUtils.java
// public static Map<String, DetailAST> getVariableNameAstMap(DetailAST classAst) {
//   List<DetailAST> variables = getVariables(classAst);
//   return variables.stream().collect(toMap(VariableUtils::getVariableName,
//                                           Function.identity(), (v1, v2) -> null,
//                                           LinkedHashMap::new));
// }


import com.puppycrawl.tools.checkstyle.api.AbstractCheck;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
import java.util.Map;
import static es.startuphero.checkstyle.util.ClassUtils.ABSTRACT_CLASS_PREFIX;
import static es.startuphero.checkstyle.util.ClassUtils.getClassName;
import static es.startuphero.checkstyle.util.ClassUtils.isEntity;
import static es.startuphero.checkstyle.util.CommonUtils.getNameWithoutContext;
import static es.startuphero.checkstyle.util.VariableUtils.getVariableNameAstMap;
package es.startuphero.checkstyle.checks.naming;



/**
 * @author ozlem.ulag
 */
public class VariableNameCheck extends AbstractCheck {

  /**
   * A key is pointing to the warning message text in "messages.properties" file.
   */
  private static final String MSG_KEY = "illegal.variable.name";

  /**
   * set entity annotation to understand that a class is an entity.
   */
  private String typeAnnotation;

  @Override
  public int[] getDefaultTokens() {
    return getAcceptableTokens();
  }

  @Override
  public int[] getAcceptableTokens() {
    return new int[] {TokenTypes.CLASS_DEF,
                      TokenTypes.INTERFACE_DEF,
                      TokenTypes.ENUM_DEF,
                      TokenTypes.ANNOTATION_DEF};
  }

  @Override
  public int[] getRequiredTokens() {
    return getAcceptableTokens();
  }

  @Override
  public void visitToken(DetailAST ast) {
    if (isEntity(ast, typeAnnotation)) {
      String className = getClassName(ast);
// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/ClassUtils.java
// public static final String ABSTRACT_CLASS_PREFIX = "Abstract";
// 
// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/ClassUtils.java
// public static String getClassName(DetailAST classAst) {
//   DetailAST type = classAst.findFirstToken(TokenTypes.LITERAL_CLASS);
//   return type.getNextSibling().getText();
// }
// 
// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/ClassUtils.java
// public static Boolean isEntity(DetailAST classAst, String fullEntityAnnotation) {
//   return AnnotationUtils.hasAnnotation(classAst, fullEntityAnnotation);
// }
// 
// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/CommonUtils.java
// public static String getNameWithoutContext(String name, String contextName) {
//   String suggestedName = "";
//   String[] separated = name.split("(?i)" + contextName);
//   for (String separatedName : separated) {
//     if (!isEmpty(separatedName)) {
//       suggestedName = suggestedName + separatedName;
//     }
//   }
//   return isEmpty(suggestedName) ? name :
//       suggestedName.substring(0, 1).toLowerCase() + suggestedName.substring(1);
// }
// 
// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/VariableUtils.java
// public static Map<String, DetailAST> getVariableNameAstMap(DetailAST classAst) {
//   List<DetailAST> variables = getVariables(classAst);
//   return variables.stream().collect(toMap(VariableUtils::getVariableName,
//                                           Function.identity(), (v1, v2) -> null,
//                                           LinkedHashMap::new));
// }


// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/checks/naming/VariableNameCheck.java
import com.puppycrawl.tools.checkstyle.api.AbstractCheck;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
import java.util.Map;
import static es.startuphero.checkstyle.util.ClassUtils.ABSTRACT_CLASS_PREFIX;
import static es.startuphero.checkstyle.util.ClassUtils.getClassName;
import static es.startuphero.checkstyle.util.ClassUtils.isEntity;
import static es.startuphero.checkstyle.util.CommonUtils.getNameWithoutContext;
import static es.startuphero.checkstyle.util.VariableUtils.getVariableNameAstMap;

package es.startuphero.checkstyle.checks.naming;



/**
 * @author ozlem.ulag
 */
public class VariableNameCheck extends AbstractCheck {

  /**
   * A key is pointing to the warning message text in "messages.properties" file.
   */
  private static final String MSG_KEY = "illegal.variable.name";

  /**
   * set entity annotation to understand that a class is an entity.
   */
  private String typeAnnotation;

  @Override
  public int[] getDefaultTokens() {
    return getAcceptableTokens();
  }

  @Override
  public int[] getAcceptableTokens() {
    return new int[] {TokenTypes.CLASS_DEF,
                      TokenTypes.INTERFACE_DEF,
                      TokenTypes.ENUM_DEF,
                      TokenTypes.ANNOTATION_DEF};
  }

  @Override
  public int[] getRequiredTokens() {
    return getAcceptableTokens();
  }

  @Override
  public void visitToken(DetailAST ast) {
    if (isEntity(ast, typeAnnotation)) {
      String className = getClassName(ast);
      if (className.startsWith(ABSTRACT_CLASS_PREFIX)) {