private Map<String, AnnotationValue> getAnnotationValues(AnnotationMirror a) {
   Map<String, AnnotationValue> values = new HashMap<String, AnnotationValue>();
   Map<AnnotationTypeElementDeclaration, AnnotationValue> elementValues = a.getElementValues();
   for (Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue> entry :
       elementValues.entrySet()) {
     values.put(entry.getKey().getSimpleName(), entry.getValue());
   }
   return values;
 }
  private static boolean checkUpdateInfo(
      AnnotationMirror mirror, MethodDeclaration methodDeclaration, EclipseMessager messager) {
    Map<AnnotationTypeElementDeclaration, AnnotationValue> valueMap = mirror.getElementValues();
    Set<Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue>> valueSet =
        valueMap.entrySet();

    for (Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue> annoKeyValue : valueSet) {
      if (annoKeyValue.getKey().getSimpleName().equals("updateInfo")) {
        checkIfAnnotationValueAttributeIsEntity(
            (AnnotationMirror) annoKeyValue.getValue().getValue(), "updateEntity", messager);
      }
    }
    return true;
  }
  private static boolean checkTransferInfoType(
      AnnotationValue annotationValue, EclipseMessager messager) {
    AnnotationMirror mirror = (AnnotationMirror) annotationValue.getValue();
    Map<AnnotationTypeElementDeclaration, AnnotationValue> valueMap = mirror.getElementValues();
    Set<Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue>> valueSet =
        valueMap.entrySet();

    for (Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue> annoKeyValue : valueSet) {
      if (annoKeyValue.getKey().getSimpleName().equals("type")) {
        String annoValue = (String) annoKeyValue.getValue().getValue();
        if (annoValue != null && annoValue.trim().length() == 0) {
          SourcePosition pos = annoKeyValue.getValue().getPosition();
          messager.printError(pos, TYPE_ATTRIBUTE_SHOULD_BE_NOT_EMPTY);
        }
        return false;
      }
    }
    return true;
  }
  public static boolean checkTransferInfo(
      AnnotationMirror mirror,
      MethodDeclaration methodDeclaration,
      boolean checkReturnType,
      EclipseMessager messager) {
    Map<AnnotationTypeElementDeclaration, AnnotationValue> valueMap = mirror.getElementValues();
    Set<Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue>> valueSet =
        valueMap.entrySet();

    boolean found = false;
    for (Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue> annoKeyValue : valueSet) {
      if (annoKeyValue.getKey().getSimpleName().equals("transferInfo")) {
        found = true;
        checkTransferInfoType(annoKeyValue.getValue(), messager);
        checkIfAnnotationValueAttributeIsEntity(
            (AnnotationMirror) annoKeyValue.getValue().getValue(), "mappedBy", messager);
        break;
      }
    }
    if (!found && checkReturnType) {
      TypeMirror returnType = methodDeclaration.getReturnType();
      String returnTypeName = returnType.toString();
      if (returnTypeName.equals("java.util.List<?>")
          || returnTypeName.equals("java.util.List")
          || returnTypeName.equals("java.util.Collection<?>")
          || returnTypeName.equals("java.util.Collection")) {
        // System.out.println(returnType);
        SourcePosition pos = mirror.getPosition();
        messager.printFixableError(
            pos,
            CLASS_OF_THE_COLLECTION_ELEMENTS_IS_NOT_SPECIFIED_AND_TRANSFER_INFO_PARAMETER_IS_MISSING,
            PLUGIN_ID,
            ERROR_transferInfo_is_missing);
        return false;
      }
    }
    return true;
  }
  public static boolean checkIfAnnotationValueAttributeIsEntity(
      AnnotationMirror mirror, String attributeName, EclipseMessager messager) {
    Map<AnnotationTypeElementDeclaration, AnnotationValue> valueMap = mirror.getElementValues();
    Set<Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue>> valueSet =
        valueMap.entrySet();

    for (Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue> annoKeyValue : valueSet) {
      if (annoKeyValue.getKey().getSimpleName().equals(attributeName)) {
        ClassDeclaration annoValue = (ClassDeclaration) annoKeyValue.getValue().getValue();
        Entity entityAnnotation = annoValue.getAnnotation(Entity.class);
        if (entityAnnotation == null) {
          SourcePosition pos = annoKeyValue.getValue().getPosition();
          messager.printError(
              pos,
              "'"
                  + attributeName
                  + "' attribute value class should be annotated with 'javax.persistence.Entity'");
          return false;
        }
      }
    }
    return true;
  }