// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/AnnotationUtils.java
// public static Map<String, Object> getKeyDefaultValueMap(String fullAnnotationName,
//                                                         Collection<String> keys) {
//   Map<String, Object> keyDefaultValueMap = new LinkedHashMap<>();
//   try {
//     Class<?> annotationClass = Class.forName(fullAnnotationName);
//     keys.forEach(key -> keyDefaultValueMap.put(key, getDefaultValue(annotationClass, key)));
//   } catch (ClassNotFoundException ignored) {
//   }
//   return keyDefaultValueMap;
// }
// 
// 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 Map<String, String> getImportSimpleFullNameMap(DetailAST rootAst) {
//   Map<String, String> simpleFullNameMapOfImports = new LinkedHashMap<>();
//   for (DetailAST sibling = rootAst; sibling != null; sibling = sibling.getNextSibling()) {
//     if (sibling.getType() == TokenTypes.IMPORT) {
//       simpleFullNameMapOfImports.put(CommonUtils.getSimpleName(sibling),
//                                      CommonUtils.getFullName(sibling));
//     }
//   }
//   return simpleFullNameMapOfImports;
// }
// 
// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/CommonUtils.java
// public static String getFullName(DetailAST ast) {
//   return FullIdent.createFullIdent(ast.findFirstToken(TokenTypes.DOT)).getText();
// }
// 
// 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];
// }


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 java.util.Optional;
import java.util.Set;
import static es.startuphero.checkstyle.util.AnnotationUtils.getKeyDefaultValueMap;
import static es.startuphero.checkstyle.util.AnnotationUtils.getKeyValueAstMap;
import static es.startuphero.checkstyle.util.AnnotationUtils.getValueAsString;
import static es.startuphero.checkstyle.util.ClassUtils.getImportSimpleFullNameMap;
import static es.startuphero.checkstyle.util.CommonUtils.getFullName;
import static es.startuphero.checkstyle.util.CommonUtils.getSimpleName;
import static java.util.Objects.nonNull;
package es.startuphero.checkstyle.checks.annotation;



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

  /**
   * A key is pointing to the warning message text in "messages.properties" file.
   */
  private static final String MSG_KEY = "redundant.default.annotation.parameter.assign";

  private Map<String, String> importSimpleFullNameMap;

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

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

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

  @Override
  public void beginTree(DetailAST rootAst) {
    importSimpleFullNameMap = getImportSimpleFullNameMap(rootAst);
  }

  @Override
  public void visitToken(DetailAST ast) {
    Map<String, DetailAST> annotationKeyValueAstMap = getKeyValueAstMap(ast);
    if (!annotationKeyValueAstMap.isEmpty()) {
// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/AnnotationUtils.java
// public static Map<String, Object> getKeyDefaultValueMap(String fullAnnotationName,
//                                                         Collection<String> keys) {
//   Map<String, Object> keyDefaultValueMap = new LinkedHashMap<>();
//   try {
//     Class<?> annotationClass = Class.forName(fullAnnotationName);
//     keys.forEach(key -> keyDefaultValueMap.put(key, getDefaultValue(annotationClass, key)));
//   } catch (ClassNotFoundException ignored) {
//   }
//   return keyDefaultValueMap;
// }
// 
// 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 Map<String, String> getImportSimpleFullNameMap(DetailAST rootAst) {
//   Map<String, String> simpleFullNameMapOfImports = new LinkedHashMap<>();
//   for (DetailAST sibling = rootAst; sibling != null; sibling = sibling.getNextSibling()) {
//     if (sibling.getType() == TokenTypes.IMPORT) {
//       simpleFullNameMapOfImports.put(CommonUtils.getSimpleName(sibling),
//                                      CommonUtils.getFullName(sibling));
//     }
//   }
//   return simpleFullNameMapOfImports;
// }
// 
// Path: startupheroes-checks/src/main/java/es/startuphero/checkstyle/util/CommonUtils.java
// public static String getFullName(DetailAST ast) {
//   return FullIdent.createFullIdent(ast.findFirstToken(TokenTypes.DOT)).getText();
// }
// 
// 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/checks/annotation/RedundantDefaultAnnotationParameterAssignCheck.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 java.util.Optional;
import java.util.Set;
import static es.startuphero.checkstyle.util.AnnotationUtils.getKeyDefaultValueMap;
import static es.startuphero.checkstyle.util.AnnotationUtils.getKeyValueAstMap;
import static es.startuphero.checkstyle.util.AnnotationUtils.getValueAsString;
import static es.startuphero.checkstyle.util.ClassUtils.getImportSimpleFullNameMap;
import static es.startuphero.checkstyle.util.CommonUtils.getFullName;
import static es.startuphero.checkstyle.util.CommonUtils.getSimpleName;
import static java.util.Objects.nonNull;

package es.startuphero.checkstyle.checks.annotation;



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

  /**
   * A key is pointing to the warning message text in "messages.properties" file.
   */
  private static final String MSG_KEY = "redundant.default.annotation.parameter.assign";

  private Map<String, String> importSimpleFullNameMap;

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

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

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

  @Override
  public void beginTree(DetailAST rootAst) {
    importSimpleFullNameMap = getImportSimpleFullNameMap(rootAst);
  }

  @Override
  public void visitToken(DetailAST ast) {
    Map<String, DetailAST> annotationKeyValueAstMap = getKeyValueAstMap(ast);
    if (!annotationKeyValueAstMap.isEmpty()) {
      String annotationSimpleName = getSimpleName(ast);