// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/AnnotationUtils.java
// public static Boolean hasAnnotation(DetailAST ast, String fullAnnotation) {
//   return CommonUtils.getSimpleAndFullNames(fullAnnotation).stream()
//                     .anyMatch(annotation -> AnnotationUtil.containsAnnotation(ast, annotation));
// }
// 
// 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/VariableUtils.java
// public static List<DetailAST> getNonStaticVariables(DetailAST classAst) {
//   DetailAST objBlock = classAst.findFirstToken(TokenTypes.OBJBLOCK);
//   return CommonUtils.getChildsByType(objBlock, TokenTypes.VARIABLE_DEF).stream()
//                     .filter(ast -> !CommonUtils.isStatic(ast))
//                     .collect(toList());
// }
// 
// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/VariableUtils.java
// public static String getVariableName(DetailAST variableAst) {
//   DetailAST type = variableAst.findFirstToken(TokenTypes.TYPE);
//   return type.getNextSibling().getText();
// }


import com.puppycrawl.tools.checkstyle.api.AbstractCheck;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
import java.util.List;
import static es.startuphero.checkstyle.util.AnnotationUtils.hasAnnotation;
import static es.startuphero.checkstyle.util.ClassUtils.isEntity;
import static es.startuphero.checkstyle.util.VariableUtils.getNonStaticVariables;
import static es.startuphero.checkstyle.util.VariableUtils.getVariableName;
package es.startuphero.checkstyle.checks.naming;



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

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

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

  /**
   * set abstract type annotation to understand that a class is abstract.
   */
  private String abstractTypeAnnotation;

  /**
   * set id annotation to understand that a variable is primary key of entity.
   */
  private String idAnnotation;

  /**
   * set generated value annotation to understand that primary key is generated.
   */
  private String generatedValueAnnotation;

  /**
   * set convenient name for variable for generated primary key.
   */
  private String suggestedGeneratedPrimaryKeyName;

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

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

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

  @Override
  public void visitToken(DetailAST ast) {
    if (isEntity(ast, typeAnnotation) || isEntity(ast, abstractTypeAnnotation)) {
      List<DetailAST> variables = getNonStaticVariables(ast);
      for (DetailAST variable : variables) {
// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/AnnotationUtils.java
// public static Boolean hasAnnotation(DetailAST ast, String fullAnnotation) {
//   return CommonUtils.getSimpleAndFullNames(fullAnnotation).stream()
//                     .anyMatch(annotation -> AnnotationUtil.containsAnnotation(ast, annotation));
// }
// 
// 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/VariableUtils.java
// public static List<DetailAST> getNonStaticVariables(DetailAST classAst) {
//   DetailAST objBlock = classAst.findFirstToken(TokenTypes.OBJBLOCK);
//   return CommonUtils.getChildsByType(objBlock, TokenTypes.VARIABLE_DEF).stream()
//                     .filter(ast -> !CommonUtils.isStatic(ast))
//                     .collect(toList());
// }
// 
// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/VariableUtils.java
// public static String getVariableName(DetailAST variableAst) {
//   DetailAST type = variableAst.findFirstToken(TokenTypes.TYPE);
//   return type.getNextSibling().getText();
// }


// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/checks/naming/GeneratedPrimaryKeyNameCheck.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.List;
import static es.startuphero.checkstyle.util.AnnotationUtils.hasAnnotation;
import static es.startuphero.checkstyle.util.ClassUtils.isEntity;
import static es.startuphero.checkstyle.util.VariableUtils.getNonStaticVariables;
import static es.startuphero.checkstyle.util.VariableUtils.getVariableName;

package es.startuphero.checkstyle.checks.naming;



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

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

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

  /**
   * set abstract type annotation to understand that a class is abstract.
   */
  private String abstractTypeAnnotation;

  /**
   * set id annotation to understand that a variable is primary key of entity.
   */
  private String idAnnotation;

  /**
   * set generated value annotation to understand that primary key is generated.
   */
  private String generatedValueAnnotation;

  /**
   * set convenient name for variable for generated primary key.
   */
  private String suggestedGeneratedPrimaryKeyName;

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

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

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

  @Override
  public void visitToken(DetailAST ast) {
    if (isEntity(ast, typeAnnotation) || isEntity(ast, abstractTypeAnnotation)) {
      List<DetailAST> variables = getNonStaticVariables(ast);
      for (DetailAST variable : variables) {
        if (hasAnnotation(variable, idAnnotation) &&