// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/AnnotationUtils.java
// public static DetailAST getAnnotation(DetailAST ast, String fullAnnotation) {
//   DetailAST simpleAnnotationAst =
//       AnnotationUtil.getAnnotation(ast, CommonUtils.getSimpleName(fullAnnotation));
//   return nonNull(simpleAnnotationAst) ? simpleAnnotationAst
//       : AnnotationUtil.getAnnotation(ast, fullAnnotation);
// }
// 
// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/AnnotationUtils.java
// public static Map<String, DetailAST> getKeyValueAstMap(DetailAST annotationAst) {
//   List<DetailAST> keyValuePairAstList =
//       CommonUtils.getChildsByType(annotationAst, TokenTypes.ANNOTATION_MEMBER_VALUE_PAIR);
//   return keyValuePairAstList.stream()
//                             .collect(Collectors.toMap(keyValuePairAst -> keyValuePairAst.getFirstChild().getText(),
//                                                       Function.identity(), (v1, v2) -> null,
//                                                       LinkedHashMap::new));
// }
// 
// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/AnnotationUtils.java
// public static Optional<String> getValueAsString(DetailAST annotationKeyValueAst) {
//   Optional<String> result = Optional.empty();
//   DetailAST annotationValueNode = getAnnotationValueNode(annotationKeyValueAst);
//   DetailAST literalValueAst = annotationValueNode.getFirstChild();
//   if (nonNull(literalValueAst)) {
//     result = Optional.of(literalValueAst.getText().replaceAll("\"", ""));
//   }
//   return result;
// }
// 
// 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 getSimpleName(String fullName) {
//   String[] packageNames = fullName.split("\\.");
//   return packageNames[packageNames.length - 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.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
import com.puppycrawl.tools.checkstyle.api.AbstractCheck;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import static es.startuphero.checkstyle.util.AnnotationUtils.getAnnotation;
import static es.startuphero.checkstyle.util.AnnotationUtils.getKeyValueAstMap;
import static es.startuphero.checkstyle.util.AnnotationUtils.getValueAsString;
import static es.startuphero.checkstyle.util.ClassUtils.isEntity;
import static es.startuphero.checkstyle.util.CommonUtils.getSimpleName;
import static es.startuphero.checkstyle.util.VariableUtils.getVariableNameAstMap;
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;
                      .forEach(checkedVariable -> {
                        DetailAST variableAst = variableNameAstMap.get(checkedVariable);
                        checkedAnnotations.forEach(checkedAnnotation -> checkAnnotation(checkedVariable,
                                                                                        variableAst,
                                                                                        checkedAnnotation));
                      });
    }
  }

  private void checkAnnotation(String checkedVariable, DetailAST variableAst,
                               String checkedAnnotation) {
    DetailAST annotationAst = getAnnotation(variableAst, checkedAnnotation);
    if (nonNull(annotationAst)) {
      Map<String, DetailAST> annotationKeyPairAstMap = getKeyValueAstMap(annotationAst);
      Map<String, String> checkedKeyValueMap = variableAnnotationKeyValueTable.get(checkedVariable, checkedAnnotation);
      checkedKeyValueMap.keySet().forEach(checkedKey -> checkKeyValuePair(checkedVariable,
                                                                          checkedAnnotation,
                                                                          annotationAst,
                                                                          annotationKeyPairAstMap,
                                                                          checkedKeyValueMap,
                                                                          checkedKey));
    }
  }

  private void checkKeyValuePair(String checkedVariable, String checkedAnnotation, DetailAST annotationAst,
                                 Map<String, DetailAST> annotationKeyPairAstMap, Map<String, String> checkedKeyValueMap,
                                 String checkedKey) {
    String checkedValue = checkedKeyValueMap.get(checkedKey);
    DetailAST annotationKeyValueAst = annotationKeyPairAstMap.get(checkedKey);
    if (nonNull(annotationKeyValueAst)) {
// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/AnnotationUtils.java
// public static DetailAST getAnnotation(DetailAST ast, String fullAnnotation) {
//   DetailAST simpleAnnotationAst =
//       AnnotationUtil.getAnnotation(ast, CommonUtils.getSimpleName(fullAnnotation));
//   return nonNull(simpleAnnotationAst) ? simpleAnnotationAst
//       : AnnotationUtil.getAnnotation(ast, fullAnnotation);
// }
// 
// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/AnnotationUtils.java
// public static Map<String, DetailAST> getKeyValueAstMap(DetailAST annotationAst) {
//   List<DetailAST> keyValuePairAstList =
//       CommonUtils.getChildsByType(annotationAst, TokenTypes.ANNOTATION_MEMBER_VALUE_PAIR);
//   return keyValuePairAstList.stream()
//                             .collect(Collectors.toMap(keyValuePairAst -> keyValuePairAst.getFirstChild().getText(),
//                                                       Function.identity(), (v1, v2) -> null,
//                                                       LinkedHashMap::new));
// }
// 
// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/AnnotationUtils.java
// public static Optional<String> getValueAsString(DetailAST annotationKeyValueAst) {
//   Optional<String> result = Optional.empty();
//   DetailAST annotationValueNode = getAnnotationValueNode(annotationKeyValueAst);
//   DetailAST literalValueAst = annotationValueNode.getFirstChild();
//   if (nonNull(literalValueAst)) {
//     result = Optional.of(literalValueAst.getText().replaceAll("\"", ""));
//   }
//   return result;
// }
// 
// 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 getSimpleName(String fullName) {
//   String[] packageNames = fullName.split("\\.");
//   return packageNames[packageNames.length - 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/annotation/VariableAnnotationKeyValueCheck.java
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
import com.puppycrawl.tools.checkstyle.api.AbstractCheck;
import com.puppycrawl.tools.checkstyle.api.DetailAST;
import com.puppycrawl.tools.checkstyle.api.TokenTypes;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import static es.startuphero.checkstyle.util.AnnotationUtils.getAnnotation;
import static es.startuphero.checkstyle.util.AnnotationUtils.getKeyValueAstMap;
import static es.startuphero.checkstyle.util.AnnotationUtils.getValueAsString;
import static es.startuphero.checkstyle.util.ClassUtils.isEntity;
import static es.startuphero.checkstyle.util.CommonUtils.getSimpleName;
import static es.startuphero.checkstyle.util.VariableUtils.getVariableNameAstMap;
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;

                      .forEach(checkedVariable -> {
                        DetailAST variableAst = variableNameAstMap.get(checkedVariable);
                        checkedAnnotations.forEach(checkedAnnotation -> checkAnnotation(checkedVariable,
                                                                                        variableAst,
                                                                                        checkedAnnotation));
                      });
    }
  }

  private void checkAnnotation(String checkedVariable, DetailAST variableAst,
                               String checkedAnnotation) {
    DetailAST annotationAst = getAnnotation(variableAst, checkedAnnotation);
    if (nonNull(annotationAst)) {
      Map<String, DetailAST> annotationKeyPairAstMap = getKeyValueAstMap(annotationAst);
      Map<String, String> checkedKeyValueMap = variableAnnotationKeyValueTable.get(checkedVariable, checkedAnnotation);
      checkedKeyValueMap.keySet().forEach(checkedKey -> checkKeyValuePair(checkedVariable,
                                                                          checkedAnnotation,
                                                                          annotationAst,
                                                                          annotationKeyPairAstMap,
                                                                          checkedKeyValueMap,
                                                                          checkedKey));
    }
  }

  private void checkKeyValuePair(String checkedVariable, String checkedAnnotation, DetailAST annotationAst,
                                 Map<String, DetailAST> annotationKeyPairAstMap, Map<String, String> checkedKeyValueMap,
                                 String checkedKey) {
    String checkedValue = checkedKeyValueMap.get(checkedKey);
    DetailAST annotationKeyValueAst = annotationKeyPairAstMap.get(checkedKey);
    if (nonNull(annotationKeyValueAst)) {
      Optional<String> annotationValueAsString = getValueAsString(annotationKeyValueAst);