public static Map.Entry<ExecutableElement, AnnotationValue> getAnnotationElementAndValue(
      AnnotationMirror annotationMirror, final String elementName) {
    checkNotNull(annotationMirror);
    checkNotNull(elementName);
    for (Map.Entry<ExecutableElement, AnnotationValue> entry :
        getAnnotationValuesWithDefaults(annotationMirror).entrySet()) {
      if (entry.getKey().getSimpleName().contentEquals(elementName)) {
        return entry;
      }
    }
    throw new IllegalArgumentException(
        String.format(
            "@%s does not define an element %s()",
            MoreElements.asType(annotationMirror.getAnnotationType().asElement())
                .getQualifiedName(),
            elementName));
  }
Returns a {@link ExecutableElement} and its associated {@link AnnotationValue} if such an
element was either declared in the usage represented by the provided {@link AnnotationMirror},
or if such an element was defined with a default.

@throws IllegalArgumentException if no element is defined with the given elementName.
common/src/main/java/com/google/auto/common/AnnotationMirrors.java